I do not see in the FluentValidation documentation that it actually guarantees a short circuit.
If you look in your source:
public virtual ValidationResult Validate(ValidationContext<T> context) { ... var failures = nestedValidators.SelectMany(x => x.Validate(context)); return new ValidationResult(failures); }
It will run through * all * validators (using SelectMany() ) and returns a list of errors.
It seems your only option is to force a Must rule check.
.Must(x => x!= null && x.Distinct().Count() == x.Count())
EDIT: I was going to assume that since Validate() is virtual, you can simply override it in your validator to make it short-circuited. But then I realized that the nestedValidators list is private. So yes, no ..
NPras source share