Hello,
First awsome job on this framework, I'm trying to setup some rules on one propperty. I want it to be not null and one of two string values. For example:
RuleFor(x => x.MyProperty).NotNull();
RuleFor(x => x.MyProperty).Equal("G");
RuleFor(x => x.MyProperty).Equal("N");
I tried to create the rule like this:
RuleFor(x => x.MyProperty) .NotNull().WithMessage("MyProperty is required.") .Equal("D").WithMessage("Invalid value.") .Equal("T").WithMessage("Invalid value.");
Here are my questions:
-
if the first rule fails, why it would still return the following rules as failed as well. if there a way to stop validation when the first rule fails?
-
how can i throw one error message for multiple errors?
-
how can i do a validation on string values with an OR? like .Equal("T" || "D")?