pouria vafaei
pouria vafaei

Reputation: 11

WithMessage method does not work after SetValidator to override the error message

Consider I have a validator like this:

public class validatorTest : AbstractValidator<model>

public validatorTest() => _ = this.RuleFor(model => model.Name).NotNull().WithMessage("Error");

and consider the parent validator as below :

public class parentValidator : AbstractValidator<List<model>>
   public parentValidator (IValidator<model> validator) => _ = this.RuleForEach(x => x).SetValidator(validator).WithMessage("Override Error");

I try to override the error message but it does not work.

Any solution?

Upvotes: 0

Views: 26

Answers (0)

Related Questions