Is there a way using data annotation to compare two model properties and report error if they are the same? I know the way using Compare to report error if different but how to do it the opposite way?
For example, the code below is direct copy from the MVC RegisterModel class
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
In the above code, the validation will fail if the Password and ConfirmPassword are different. What I want is the opposite, I want to report the error if the Password and ConfirmPassword are the same.
I know I can create my own ValidationAttribute but just wondering if there's one already built-in for validate the opposite.