title: Customized DataAnnotationsModelMetadataProvider not working
body: <p>I have many properties that require 1 or more validation attributes, like the following:</p>
  
  <pre><code>public class TestModel
  {
      [Some]
      [StringLength(6)]
      [CustomRequired] // more attributes...
      public string Truck { get; set; }
  }
  </code></pre>
  
  <p>Please note all the above annotations work.</p>
  
  <p>I do not want to write that all the time because whenever <code>Some</code> is applied, all other attributes are also applied to the property. I want to be able to do this:</p>
  
  <pre><code>public class TestModel
  {
      [Some]
      public string Truck { get; set; }
  }
  </code></pre>
  
  <p>Now this is doable by inheriting; therefore, I wrote a custom <code>DataAnnotationsModelMetadataProvider</code> and overrode the <code>CreateMetadata</code>. This looks for anything that is decorated with <code>Some</code> and then adds more attributes to it:</p>
  
  <pre><code>public class TruckNumberMetadataProvider : DataAnnotationsModelMetadataProvider
  {
      protected override ModelMetadata CreateMetadata(IEnumerable&lt;Attribute&gt; attributes, Type containerType, Func&lt;object&gt; modelAccessor, Type modelType, string propertyName)
      {
          var attributeList = attributes.ToList();
          if (attributeList.OfType&lt;SomeAttribute&gt;().Any())
          {
              attributeList.Add(new StringLengthAttribute(6));
              attributeList.Add(new CustomRequiredAttribute());
          }
  
          return base.CreateMetadata(attributeList, containerType, modelAccessor, modelType, propertyName);
      }
  }
  </code></pre>
  
  <p>These are the attributes in case it helps:</p>
  
  <pre><code>public class CustomRequiredAttribute : RequiredAttribute
  {
      public CustomRequiredAttribute()
      {
          this.ErrorMessage = "Required";
      }
  }
  public class SomeAttribute : RegularExpressionAttribute
  {
      public SomeAttribute()
          : base(@"^[1-9]\d{0,5}$")
      {
      }
  }
  </code></pre>
  
  <p><strong>Usage</strong></p>
  
  <pre><code>@Html.TextBoxFor(x =&gt; x.Truck)
  </code></pre>
  
  <p>HTML Rendered:</p>
  
  <pre><code>&lt;input name="Truck" id="Truck" type="text" value="" 
      data-val-required="The Truck field is required." 
      data-val-regex-pattern="^[1-9]\d{0,5}$" 
      data-val-regex="The field Truck must match the regular expression '^[1-9]\d{0,5}$'." 
      data-val="true"&gt;
  &lt;/input&gt;
  </code></pre>
  
  <p><strong>Problems/Questions</strong></p>
  
  <ol>
  <li>The <code>CustomRequired</code> was applied. But why does it pick up the message from the base class <code>RequiredAttribute</code> if I am using <code>CustomRequired</code>. The <code>data-val-required</code> should just say <em>Required</em>.</li>
  <li>The <code>StringLenth</code> of 6 chars is not applied. There is no sign of anything rendered for <code>StringLength</code>, why?</li>
  </ol>