schemani 0.0.1-alpha.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 48

schemani #

Simple and extensible data schema validation for Dart and Flutter. If you know Yup and Laravel Validation you will feel like home using this package.

Please note that the schemani/formini packages are under development. There are still some issues to resolve before this has any help for real use cases. #roadmap

Usage #

import 'package:schemani/schemani.dart';

main() {
  const userSchema = MapSchema({
    'name': [Required()],
    'email': [Required(), Email()],

  try {
      'name': null,
      'email': 'foo',
  } on MapValidationException catch (e) {
    e.exceptions.forEach((field, exception) {
      print('$field => $exception');

Will throw MapValidationException only once combining the inner ValidationExceptions.

flutter: name => Required field
flutter: email => Invalid email address

Usage with formini #

Use schemani_formini package for validating formini values using schemas. Or just copy the one simple file to your project.

API reference #

Contributing #

Please open an issue or pull request in GitHub. Any help and feedback is much appreciated.

flutter pub pub run test

Licence #


Roadmap #

  • ListSchema
  • Rules
    • References to another fields inside a rule
    • More basic rules (min, max, between, url, etc...)
  • i18n ValidationException.toString()
  • Benchmarking

[0.0.1-alpha.3] - 2019/09/26 #

  • Add support for nested MapSchemas

[0.0.1-alpha.2] - 2019/09/26 #

  • Remove flutter dependencies

[0.0.1-alpha.1] - 2019/09/23 #

  • First release


import 'package:schemani/schemani.dart';

void main() {
  const userSchema = MapSchema({
    'name': [Required()],
    'email': [Required(), Email()],
    'profile': MapSchema({
      'avatar': [Required()],

  try {
    userSchema.validate({'name': null, 'email': ''});
  } on MapValidationException catch (e) {

/// MapValidationExceptions handler.
handle(MapValidationException e) {
  e.exceptions.forEach((field, exception) {
    if (exception is MapValidationException) {
      return handle(exception);

    print('$field => $exception');

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  schemani: ^0.0.1-alpha.3

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:schemani/schemani.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Apr 4, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health suggestions

Fix lib/src/rules/email.dart. (-0.50 points)

Analysis of lib/src/rules/email.dart reported 1 hint:

line 15 col 24: Unnecessary new keyword.

Maintenance suggestions

The package description is too short. (-15 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Package is pre-release. (-5 points)

Pre-release versions should be used with caution; their API can change in breaking ways.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
Dev dependencies
test ^1.8.0