I have this :
public class Customer
{
[DisplayName("Lastname"), StringLength(50)]
[Required(ErrorMessage="My Error Message")]
[NotEmpty()]
public override string LastName { get; set; }
[DisplayName("Firstname"), StringLength(50)]
[Required(ErrorMessage="My Error Message 2")]
[NotEmpty()]
public override string FirstName{ get; set; }
}
In the controller, I do this :
if (!TryValidateModel(myCustomer))
{
//HERE
....
}
Where "HERE" is, I'd like get all error messages.
Some sample cases :
- If "LastName" is missing I'd like get "My Error Message"
- If both are mising, I'd like get a List (or other) with the values "My Error Message" and "My Error Message 2"
Any idea ?
Thanks,