If I have two validators, a NotNullValidator and a StringLengthValidator, is there a way to get only a Null Validation Error and not both. For example:
public class Test
{
[NotNullValidator(MessageTemplate="Name is required"),
StringLengthValidator(1,50, MessageTemplate="Name must be between 1 and 50 characters")]
public string Name { get; set; }
}
Test test = new Test {Name = null};
ValidationResults r = Validation.Validate(test);
if (!r.IsValid)
{
foreach (var test in r)
{
Console.WriteLine(test.Message);
}
}
In this case I get both validation errors. I get one telling me that the "Name is required" and another telling me that it should be between 1 and 50 characters. I only want to see that name is required in this case. Is this possible?