I'm using the module-level validator: 'PropertiesMustMatch' on my view-model, like so:
[PropertiesMustMatch("Password", "PasswordConfirm")]
public class HomeIndex
{
[Required]
public string Name { get; set; }
public string Password { get; set; }
public string PasswordConfirm { get; set; }
}
I'm noticing that if I submit the form without Name filled in, the ValidationSummary() helper returns only the following error:
- The Name field is required.
However, if I fill in Name, then ValidationSummary() will return a PropertiesMustMatch error:
- 'Password' and 'PasswordConfirm' do not match.
So it looks like the property-level validators are being evaluated first, then the model-level validators.
I would much prefer if they were all validated at once, and ValidationSummary would return:
- The Name field is required.
- 'Password' and 'PasswordConfirm' do not match.
Any ideas what I can do to fix this?
I'm studying the MVC 2 source-code to try to determine why this happens.