Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Latest commit

 

History

History
52 lines (37 loc) · 1.41 KB

README.md

File metadata and controls

52 lines (37 loc) · 1.41 KB

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.

Usage

import 'package:schemani/schemani.dart';

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

  try {
    userSchema.validate({
      'name': null,
      'email': 'foo example.org',
    });
  } 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

https://pub.dev/documentation/schemani

Contributing

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

flutter pub pub run test

Licence

MIT