I have a custom validation that is not evaluating, apparentlly. My validation validates dates but when I submit an invalid date, say 02/29/2017 (invalid not leap year) I get a message saying that the string is not valid for the object property. This is not good because in my country we speak portuguese and the English message really gets in the way, besides, I want to perform my custom validation.
[Required(ErrorMessage = "O campo DATA DE NASCIMENTO é obrigatório")]
[DataValida( ErrorMessage = "O campo DATA DE NASCIMENTO é inválido")]
public DateTime DataNascimento { get; set; }
my validation
public class DataValida : ValidationAttribute
{
public override bool IsValid(object value)
{
DateTime dt;
bool resultado = DateTime.TryParse(value.ToString(),out dt);
return resultado;
}
}
Where does this message comes from?