We need to resolve dataAnnotations at runtime for the nature of the project and configuration. Apparently one of the options (without using custom attributes preferably) is to subclass DataAnnotationsModelValidatorProvider
and override its GetValidators
method. Later in the global.axax.cs the new class in added as ModelValidatorProviders.Providers.Add(new CustomCoolProvider());
Question: Is this still valid for MVC 5?
The idea behind this implementation is to replace some formatted values set as data annotations, for example: [Display(Name="COOL.VALUE")]
will be understood and replace for some other value: metadata.DisplayName = "Some super cool value"
Here someone wrote an example for a prev version of MVC. DataAnnotations dynamically attaching attributes
Help is appreciated.