Release notes
- Add support for ASP.NET Core 3.
- Add ASP.NET Core-compatible version of the email address validator.
- Simplify the advanced test-helper syntax.
- Add support for defining child rules inline when using
RuleForEach
. ValidatorDescriptor
now has consistent handling of model-level rules.RuleForEach
can now access collection index in error message with{CollectionIndex}
placeholder.- Welsh language translations of default error messages.
- Hungrian language translations of default error messages.
- Indonesian language translations of default error messages.
- Using
RuleForEach
combined withWhen
has more intuitive behaviour. - Fixed order of rule execution when using async validation.
Of these new features, the main one to note is the new ChildRules
syntax. When defining a rule against a collection of complex types, rules for the child properties can be defined directly inline rather than having to use a child validator:
public class CustomerValidator : AbstractValidator<Customer> {
public CustomerValidator() {
RuleForEach(x => x.Orders).ChildRules(order => {
order.RuleFor(x => x.ProductName).NotNull();
order.RuleFor(x => x.Amount).GreaterThan(0);
});
}
}
Downloads
Binaries can be downloaded from nuget:
- FluentValidation - Main package
- FluentValidation.AspNetCore - ASP.NET Core integration
- FluentValidation.WebApi - Legacy ASP.NET Web Api 2 integration (deprecated)
- FluentValidation.Mvc5 - Legacy ASP.NET MVC 5 integration (deprecated)