is there a way to use conditional validation on MVC3 model?
for example:
public class User
{
[Required]
public string Password { get; set; }
[Required, Compare("Password")]
public string ComparePassword { get; set; }
}
Where i would like Password and confirmpassword fields to be required ONLY when adding a new user. However when editing I would like these to be empty (text boxes in the view). Only when user does type in a new Password and ConfirmPassword will the password be changed in the DB.
Thanks