Manual Validation with Data Annotations
Posted by: K. Scott Allen,
on 30 Jun 2011 |
View original | Bookmarked: 0 time(s)
Several people have asked me about using data annotations for validation outside of a UI framework, like ASP.NET MVC or Silverlight. The System.ComponentModel.DataAnnotations assembly contains everything you need to execute validation logic in the annotations. Specifically, there is a static Validator class to execute the validation rules. For example, let's say you have the following class in a console mode application: public class Recipe
{
[Required]
public string Name { get; set; }
}
You...