Given a simplified class, like below:
public class Cliente
{
[Display(Name = "Usuário")]
[Required(ErrorMessage = "Informe um nome de usuário")]
[EmailAddress(ErrorMessage = "Informe um e-mail válido")]
[Remote("verificarUsernameCadastrado", "Validate", HttpMethod = "POST")]
public String Username { get; set; }
}
I'm relatively new on the MVC world and I was thinking.. Is there a way to get, in the controller, the custom error message used with data annotation?
For instance, if I access the property Username in an action, I'd like to get the error message that I gave for EmailAddress (in this case, "Informe um e-mail válido").
I can easily duplicate this message where I want to use, but I'd really like to know if it's possible to do that.
Thanks in advance!