FluentValidation
A .NET library for writing validation rules as classes with a fluent API, such as RuleFor(x => x.Price).GreaterThan(0).
In more detail
It suits rules with conditions or composition that attributes cannot express, and the rules can be reused outside HTTP. Register validators with dependency injection and run them before the application service.
Related terms
- model validation — Checking that incoming data meets the rules, such as required fields and ranges, before the application acts on it.
- data annotations — Attributes from System.ComponentModel.DataAnnotations, such as [Required] and [Range(1, 200)], that declare simple validation rules on properties.
- fluent API — An API designed so each call returns an object you can call the next method on, letting configuration read as one chained sentence.
Taught in
- Model Validation and FluentValidation — Modern .NET Core, C# & Enterprise Microservices