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.
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 ValidationException
s.
flutter: name => Required field
flutter: email => Invalid email address
Use schemani_formini package for validating formini values using schemas. Or just copy the one simple file to your project.
https://pub.dev/documentation/schemani
Please open an issue or pull request in GitHub. Any help and feedback is much appreciated.
flutter pub pub run test
MIT