Skip to content

Instantly share code, notes, and snippets.

@kouphax
Created October 16, 2010 20:34
Show Gist options
  • Save kouphax/630234 to your computer and use it in GitHub Desktop.
Save kouphax/630234 to your computer and use it in GitHub Desktop.
public class PasswordsMustMatchAttribute : ValidationAttribute
{
protected override ValidationResult IsValid(
object value, ValidationContext validationContext)
{
var model = validationContext.ObjectInstance as Person;
if (model.Password == model.PasswordConfirm)
{
return ValidationResult.Success;
}
return new ValidationResult(
"Password and Password Confirmation must match",
new string[] { "Password", "PasswordConfirm" });
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment