title: ASP.NET MVC data annotations client side validation with inherited RegularExpressionAttribute
body: <p>To keep my model validation clean I would like to implement my own validation attributes, like <code>PhoneNumberAttribute</code> and <code>EmailAttribute</code>. Some of these can favorably be be implemented as simple classes that inherit from <code>RegularExpressionAttribute</code>.</p>
  
  <p>However, I noticed that doing this breaks client side validation of these attributes. I am assuming that there is some kind of type binding that fails somewhere.</p>
  
  <p>Any ideas what I can do to get client side validation working?</p>
  
  <p><strong>Code example</strong>:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public sealed class MailAddressAttribute : RegularExpressionAttribute
  {
      public MailAddressAttribute()
          : base(@"^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$")
      {
      }
  }
  </code></pre>