So in MVC when using the .NET Membership system, password policies are defined in the web.config file. For example minPasswordLength is defined in membership->profiles.
When using a View this is accessible using the @Membership
component
Passwords must be at least @Membership.MinRequiredPasswordLength characters long.
However if you look at the default model in the example MVC Application it says
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "New Password")]
public string NewPassword { get; set; }
The part I am curious about is the MinimumLength = 6
since this is hard coded it would mean that if I ever wanted to update the password length, I'd not only have to edit the web.config (like Microsoft suggest) but also search any references to it in the source and change all over the place (probably not the best programming practise).
Is there any ways of using variables in Attributes. I suspect not since this probably happens at compile time rather than runtime. If there isn't does anyone know of a better pattern to stop me having to find replace all references in the future?