i\'m defining a validation for my Request objects. I would like the validator to stop on the very first failure, not only the one on the same chain. In the example below, if my
Just add SetValidator
before running the rules that depend on them, using a Custom
condition:
//if InpatOrderImportValidatorBllNode fail ,the custom method cannot be executed
RuleFor(x => x).Cascade(CascadeMode.StopOnFirstFailure)
.SetValidator(new InpatOrderImportValidatorBllNode())
.Custom((input, context) => {
context.AddFailure(new ValidationFailure("DrugTypeName", "fail"));
});