I want to set the data annotation (display) of a field based on a variable or function:
public class InputModel
{
[Required]
[StringLength(100, ErrorMessage = VARIABLE or FUNCTION())]
[Display(Name = "Password - must use at least 12 characters")]
[DataType(DataType.Password)]
public string Password { get; set; }
}
How do you set data annotation programmatically?
InputModel.DataAnnotation.Display = "Foo";
How would you set the data annotation in the model to a variable or function?