schemani 0.0.1-alpha.3 copy "schemani: ^0.0.1-alpha.3" to clipboard
schemani: ^0.0.1-alpha.3 copied to clipboard

Simple and extensible data schema validation.

example/schemani.dart

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': 'example.org'});
  } on MapValidationException catch (e) {
    handle(e);
  }
}

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

    print('$field => $exception');
  });
}
0
likes
30
pub points
0%
popularity

Publisher

unverified uploader

Simple and extensible data schema validation.

Repository (GitHub)
View/report issues

License

MIT (license)

More

Packages that depend on schemani