github FluentValidation/FluentValidation 8.5.0

latest releases: 11.9.1, 11.9.0, 11.8.1...
4 years ago

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 with When 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:

Don't miss a new FluentValidation release

NewReleases is sending notifications on new releases.