I am creating an MVC 3 application that needs to set runtime data validation rules based on external data (e.g. Required, MinimumLength, MaximumLength). It is natural to use data annotations in MVC 3, however, property attributes that provide validation metadata are set at compile time.
Is there a template for using data annotations with metadata provided at runtime?
Example:
public string Text { get; set; } public void SetIsRequired(string propertyName, bool required) {
I know TypeDescriptor , but I donβt see the ability to change instance property attributes (only class level attributes for an instance or property level attributes for a type).
source share