title: C# WebAPI Custom attribute validation not working
body: <p>I have a custom validation attribute which isn't triggering. Please refer to the following code for more details.</p>
  
  <pre><code>public HttpResponseMessage GetTestResponse()
          {
              var model = new TestClass1()
              {
                  Id = 1,
                  address = new Address() { StreetName = "test" }
              };
              bool validateAllProperties = false;
  
              var results = new List&lt;ValidationResult&gt;();
  
              bool isValid = Validator.TryValidateObject(
                  model,
                  new ValidationContext(model, null, null),
                  results,
                  validateAllProperties);
              if (isValid)
              {
                  return new HttpResponseMessage(HttpStatusCode.OK);
              }
              else
              {
                  return Request.CreateErrorResponse(HttpStatusCode.BadRequest);
              }
          }
      public class TestClass1
      {
  
          public string Name { get; set; }
          [Required,Range(1,5)]
          public int Id { get; set; }
          [Required]
          [ValidateObject("StreetNumber is required")]
          public Address address { get; set; }
      }
      public class Address
      {
          [Required]
          public int? StreetNumber { get; set; }
          public string StreetName { get; set; }
  
      }
      public class ValidateObjectAttribute : ValidationAttribute
      {
          public ValidateObjectAttribute(string errorMessage)
          {
              ErrorMessage = errorMessage;
          }
          protected override ValidationResult IsValid(object value, 
          ValidationContext validationContext)
          {
              var results = new List&lt;ValidationResult&gt;();
              var context = new ValidationContext(value, null, null);
  
              Validator.TryValidateObject(value, context, results, true);
  
              if (results.Count != 0)
              {
                  var compositeResults = new CompositeValidationResult(String.Format("Validation for {0} failed!", validationContext.DisplayName));
                  results.ForEach(compositeResults.AddResult);
  
                  return compositeResults;
              }
  
              return ValidationResult.Success;
          }
      }
  
      public class CompositeValidationResult : ValidationResult
      {
          private readonly List&lt;ValidationResult&gt; _results = new List&lt;ValidationResult&gt;();
  
          public IEnumerable&lt;ValidationResult&gt; Results
          {
              get
              {
                  return _results;
              }
          }
  
          public CompositeValidationResult(string errorMessage) : base(errorMessage) { }
          public CompositeValidationResult(string errorMessage, IEnumerable&lt;string&gt; memberNames) : base(errorMessage, memberNames) { }
          protected CompositeValidationResult(ValidationResult validationResult) : base(validationResult) { }
  
          public void AddResult(ValidationResult validationResult)
          {
              _results.Add(validationResult);
          }
      }
  </code></pre>
  
  <p>The custom attribute not triggering and the isvalid returning true, which should be false as one of the property inside Address class is required and is not being provided.
  Is there a a piece missing that I should be adding in order to make this work?</p>