Otherwise I always need to check if the value is null
before performing any other validations. It's kinda annoying if I have many custom checks that are using Must()
.
I placed NotEmpty()
at the very top of it therefore it already returns false, is it possible to stop there?
Example
RuleFor(x => x.Name)
.NotEmpty() // Can we not even continue if this fails?
.Length(2, 32)
.Must(x =>
{
var reserved = new[] {"id", "email", "passwordhash", "passwordsalt", "description"};
return !reserved.Contains(x.ToLowerInvariant()); // Exception, x is null
});