title: Troubles with implementing IClientValidatable- GetClientValidationRules never fires
body: <p>I am building a custom validator for my MVC4 application. To keep things simple and focus on the purpose of this question let's say that I'm reimplementing the <code>RequiredAttribute</code> class's server and client side validation:</p>
  
  <pre><code>[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
  public class MyRequiredAttribute: ValidationAttribute, IClientValidatable
  {
      public MyRequiredAttribute() : base("The {0} field is required.")
      {
      }
  
      protected override ValidationResult IsValid(object value, ValidationContext validationContext)
      {
          if (value == null)
          {
              return new ValidationResult(FormatErrorMessage(validationContext.DisplayName));
          }
          return null;
      }
  
      public IEnumerable&lt;ModelClientValidationRule&gt; GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
      {
          yield return new ModelClientValidationRequiredRule(ErrorMessage = FormatErrorMessage(metadata.GetDisplayName()));
      }
  }
  </code></pre>
  
  <p>To test this I have a very simple controller:</p>
  
  <pre><code>public class TestController : Controller
  {
      public ActionResult Index()
      {
          return View(new MyThing {Value = "whatever"});
      }
      [HttpPost]
      public ActionResult Index(MyThing thing)
      {
          if (ModelState.IsValid)
          {
              return Content("Good choice!");
          }
          return View(thing);
      }
  }
  </code></pre>
  
  <p>and a very simple model:</p>
  
  <pre><code>public class MyThing
  {
      [MyRequired]
      public string Value { get; set; }
      [Required]
      public string OtherValue { get; set; }
  }
  </code></pre>
  
  <p>and finally the Index View:</p>
  
  <pre><code>@model MyThing
  
  @{
      Layout = "~/Views/Shared/_LayoutWithAllTheAppropriateValidationScripts.cshtml";
  }
  
  &lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta name="viewport" content="width=device-width" /&gt;
      &lt;title&gt;Index&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div&gt;
          @using(Html.BeginForm()){
          @Html.ValidationSummary(true)
          @Html.EditorForModel()
          &lt;input type="submit" value="submit"/&gt;
          }
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>You'll note that I have <code>Value</code> which is decorated with the custom <code>MyRequiredAttribute</code> and <code>OtherValue</code> which is decorated with the standard <code>RequiredAttribute</code>.</p>
  
  <p>Both of these work beautifully server-side and return the appropriate validation messages on postback, but only the standard <code>RequiredAttribute</code> works on the client side. Since I'm using a <code>ModelClientValidationRequiredRule</code> instead of a <code>ModelClientValidationRule</code> with a custom <code>ValidationType</code> property I'm assuming that no custom clientside validation rules need to be defined, but I don't know that for sure because I haven't been able to get that far. The debugger never breaks inside of the <code>GetClientValidationRules</code> method and the input html element generated for the <code>Value</code> property on my model does not have the <code>data-val-required</code> and <code>data-val</code> attributes as does the <code>OtherValue</code> field, which I'm assuming is what the <code>GetClientValidationRules</code> method is responsible for doing.</p>
  
  <p>I must be missing something simple here... what is it?</p>