I'm using the CustomValidationAttribute like this
[CustomValidation(typeof(MyValidator),"Validate",ErrorMessage = "Foo")]
And my validator contains this code
public class MyValidator { public static ValidationResult Validate(TestProperty testProperty, ValidationContext validationContext) { if (string.IsNullOrEmpty(testProperty.Name)) { return new ValidationResult(""); <-- how can I get the error message from the custom validation attribute? } return ValidationResult.Success; } }
So how can I get the error message from the custom validation attribute?