title: StringLength attribute, client side validation and a membership provider
body: <p>How do I pass a value from Membership Provider (taken from web.config) to Validation Attributes in AccountModels in default MVC 3 project?</p>
  
  <pre><code>Membership.MinRequiredPasswordLength
  </code></pre>
  
  <p>returns value obtained from web.config and Register.cshtml view uses it:</p>
  
  <pre><code>&lt;p&gt;
  Passwords are required to be a minimum of @Membership.MinRequiredPasswordLength
  characters in length.
  &lt;/p&gt;
  </code></pre>
  
  <p>But it seems that ViewModel in AccountModels file have the values hard-coded in:</p>
  
  <pre><code>[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; }
  </code></pre>
  
  <p>So how do I pass the value from web.config to MinimumLength parameter?</p>