Validation attributes in System.ComponentModel.DataAnnotations is very helpful in ASP.NET MVC 3.
There is a built in method called ModelState.IsValid which will tell me whether the current model bound to the view is valid or not, but want if I want to validate any arbitrary model that uses Validation Attributes. I am looking for a helper method that looks something like this:
Pseudo-code:
List<RuleViolation> brokenRules = ValidationHelper.GetValidationErrors(customer);
I know there has to be such a helper method in the System.ComponentModel namespace, or the ASP.NET MVC 3 namespaces, but I can’t find it.
In general you should use Validator class to validate an object, or a property of it.