title: Validating a List<T> To ensure list contains at list one Item with Data Annotations MVC C#
body: <p>I'm trying to validate a generic list e.g <code>List&lt;Sales&gt;</code> so that the list should contain at least one item  added via check boxes. </p>
  
  <p>Here is how I've tried to work this:</p>
  
  <pre><code>  public class SalesViewModel :IValidatableObject
      {
  
          [Required]
          public List&lt;Sales&gt; AllSales{ get; set; }
  
  
          public IEnumerable&lt;ValidationResult&gt; Validate(ValidationContext validationContext)
          {
              if (AllSales.Length == 0)
                  yield return new ValidationResult("Please pick one sales item");
          }
      }
  </code></pre>
  
  <p>Just want to know if this is the right approach to this kind of scenario.</p>