Package selection guidance compiled from public package information, community data, and project usage.
Verify is a Flutter/Dart package that simplifies form and state validation through an intuitive, extension-based DSL. It enables developers to define validation rules concisely using fluent syntax directly on data types. The package supports customizable validation logic and integrates seamlessly into existing workflows without requiring boilerplate code. Designed for ease of use, it enhances readability and maintainability of validation logic across multiple platforms.
Use cases
Form input validation
State validation in UI components
Real-time user feedback
Custom validation rules
Cross-platform validation
Simplifying complex validation logic
Key features
Extension-based DSL
Minimal boilerplate
Chainable validation methods
Supports custom validators
Works across all Flutter platforms
Easy integration with existing code
Suitable for
Developers seeking simple validation
Teams prioritizing clean code
Apps with extensive form inputs
Projects targeting multiple platforms
Frontend-focused Flutter applications
Considerations
Limited to basic validation patterns
No built-in internationalization
Requires understanding of Dart extensions
Not ideal for highly dynamic validation logic
May need additional setup for complex scenarios
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
Validations made simple
A fp inspired validation DSL. For Dart and Flutter projects.
Features
Completely extensible (create your own combinators, validator primitives, etc)
Flexible Verify is an extension based API (There is not single class created its all pure functions)
Customizable (Define you own error types if required) organize validators how ever you want
Bloc friendly (See examples for a concrete implementation)
Null safe (as a prerelease)
Usage
Creating validators
A Validator is just a simple function alias:
// One of 2 variats depending on wether the validated subject will be transformed into another type or nottypedefValidatorT<S, T> = Either<List<dynamic>, T> Function(S subject);
typedefValidator<S> = Either<List<dynamic>, S> Function(S subject);
So you can create your own validator by just specifying a function for example:
Note: The difference between check and checkField is that the later ignore the verification when the value is null,
this will likely change in next version supporting null safety.
Run a validator
Running a validator is a simple as passing in a parameter since its just a function.
To be a bit more eloquent a verify method is provided, this method is special because besides
forwarding the argument to the calling validator it can also be used to filter the error list and
have it cast to a specific error type. Just supply a specific type parameter.
final signUpValidation = Verify.subject<SignUpState>();
final errors = signUpValidation
.verify<SignUpError>(newState); // Either<List<SignUpError>, SignUpState>
Built in validators
Verify doesn't come with many built in validators, because they are so simple to create.
It does come with some regex shorthands.
final validator = Verify.fromRegex(RegExp(r"(^\d+$)", error: Error('not just digits')) // Validator<String, int>
Form validation
Often times you will have modeled your error type similar to: