depending on configuration at each site, some fields on a form may or may not be required. Can I apply the [Required] attribute to fields of my ViewModel in code? I'd like to take advantage of all the conveniences of form validation, but I can't hard-code the [Required] attribute.
2 Answers
Checkout FluentValidation.NET. It could be used as a replacement of Data Annotations and has great integration with ASP.NET MVC. It allows you to define dynamic validation rules based on runtime conditions.