fluent_validation
2.1.1, released 4 years ago by an unverified publisher
A Dart port of FluentValidation providing chainable rule definitions for object validation.
WASM-ready
What it does
It lets you declare validation rules for model properties using a fluent API. The validator returns a result with error details such as key, message, and code.
AI-written summary of version 2.1.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need reusable, declarative validation logic separate from UI
- You want chainable, readable rule definitions similar to FluentValidation in C#
- You prefer a lightweight solution without code generation
Skip it when
- You require built‑in UI widgets for displaying errors
- You need extensive localization support (not yet implemented)
- You prefer annotation‑based or code‑gen validators
Strengths
- Fluent, chainable API is easy to read
- Supports many common validators and custom 'must' matcher
- Null‑safe and works on all Flutter platforms
Weaknesses
- No code‑gen, so you write validators manually
- Limited localization support
- Only basic validators; more complex scenarios need custom logic
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
class UserValidator extends AbstractValidator<User>{
UserValidator(){
ruleFor((u)=>u.age,key:'age').isNotNull().greaterThanOrEqual(13);
ruleFor((u)=>u.name,key:'name').isNotEmpty();
}
}
final validator=UserValidator();
ValidationResult result=validator.validate(user);Alternatives
Packages that do the same job and could replace fluent_validation.
- email_validator
Provides a simple email‑validation function without needing a full validation framework
50Compare