github FluentValidation/FluentValidation 9.1.3

latest releases: 11.9.0, 11.8.1, 11.8.0...
3 years ago

Release notes

Please read the upgrade guide if you are moving from 8.x to 9.x

Changes in 9.1.3

  • Fix an issue with IncludeRulesNotInRuleSet not working correctly (#1493)

Changes in 9.1.2

  • Make the ValidationContext.ThrowOnFailures getter public.

Changes in 9.1.1

  • Update incorrect wording in CascadeMode.StopOnFirstFailure deprecation warning.

Changes in 9.1.0

  • Add new Validate extension methods that allow options to be configured using a strategy (#1467)
  • Introduce CascadeMode.Stop and deprecate CascadeMode.StopOnFirstFailure to resolve confusion/abiguity about setting the cascade mode at validator-level (#1437)
  • RaiseValidationException can be overridden to customize the exception throwing process (#1162)
  • Make ruleset separator character splitting consistent (#1424)
  • Transform now works with RuleForEach (#1450)
  • Introduce constants for rulesets (#1435)
  • Resolve issue when attempting to use asynchronous conditions in a synchornous validaiton run (#1438)
  • Added asynchronous versions of the TestHelper methods (#1423)

Example of using the new validation strategy:

// Validate specific rulesets
validator.Validate(instance, opt => {
  opt.IncludeRuleSets("MyRuleSet", "SomeOtherRuleSet");
  
  // Can also force rules not in a ruleset to be run
  opt.IncludeRulesNotInRuleSet();
});

// Validate specific properties
validator.Validate(instance, opt => {
  opt.IncludeProperties("Forename", "Surname");
  // or
  opt.IncludeProperties(x => x.Surname, x.Forename);
});

// Throw exceptions on failure
validator.Validate(instance, opt => {
   opt.ThrowOnFailures();
});

// Combine various options
validator.Validate(instance, opt => {
  opt.IncludeRuleSets("MyRuleSet", "SomeOtherRuleSet").IncludeRulesNotInRuleSet();
  opt.ThrowOnFailures();
});

Downloads

Binaries can be downloaded from nuget:

Don't miss a new FluentValidation release

NewReleases is sending notifications on new releases.