From the FluentValidation documentation I learned that I can abort validation by setting the cascade mode.
RuleFor(x => x.Surname)
.Cascade(CascadeMode.StopOn
According to the JeremyS' answer, I have misunderstood the purpose of the CascadeMode
. It is in fact not intended to have effect on a validator level but only within a rule.
You can set CascadeMode at the global level by setting
ValidatorOptions.CascadeMode = CascadeMode.StopOnFirstFailure;
or at property level by
RuleFor(x => x.PropertyName)
.Cascade(CascadeMode.StopOnFirstFailure)