title: How to override DataAnnotations Required tag to allow conditional client side validation
body: <p>I am using DataAnnotations tags for client-side validation in ASP.NET MVC2.  I am using the <strong>Required</strong> tag, but in my case marking a field as required is not always an absolute.  I have other conditions that determine whether or not a field is required.</p>
  
  <p>Is it possible to override the required tag to allow for this conditional logic?</p>
  
  <p>I would like to do something like this:</p>
  
  <pre><code>public class ConditionalRequiredAttribute : RequiredAttribute
  {
      public ConditionalRequiredAttribute(string someParameter)
      {
          //Logic to determine if this field is required.
      }
  }
  </code></pre>
  
  <p>And then use this attribute like this:</p>
  
  <pre><code>[ConditionalRequired("some parameter info")]
  public virtual string EMailAddress { get; set; }
  </code></pre>
  
  <p>Any suggestions on how to make this work for client-side validation?</p>
  
  <p>Thanks!</p>