I have following ViewModel:
public IEnumerable<SelectListItem> SelectAdminsInGroup { get; set; }
public IEnumerable<SelectListItem> SelectAdminsNotInGroup { get; set; }
public model.Admin Admin { get; set; }
Admin class:
[PropertiesMustMatchAttribute("Password","ConfirmPassword")] public class Admin { public Admin() { this.PasswordDate = DateTime.Now; this.Username = string.Empty; }
public virtual int AdminId { get; set; }
[Required(ErrorMessage = "Field 'Username' is required"), StringLength(20, ErrorMessage = "Field 'Username' must be less than 20 characters long")]
public virtual string Username { get; set; }
public virtual string Oldusername { get; set; }
[ValidatePasswordLength()]
public virtual string Password { get; set; }
public virtual string ConfirmPassword { get; set; }
public virtual ICollection<AdminGroup> AdminGroup { get; set; }
}
Now for some reason PropertiesMustMatch never displays the error message in the validation summary. i also noticed that one of the ModelState keys contains "Admin" for "PropertiesMustMatchAttribute" and it should be blank since this would be the class/summary error message. How would i validate my custom model? thanks