title: fluent validation - How to loop through List<string>
body: <p>This is my xml :</p>
  <pre><code>  &lt;recordset&gt;
    &lt;!-- multiple value record--&gt;
    &lt;record&gt;
      &lt;KeyName&gt;aliases&lt;/KeyName&gt;
      &lt;KeyValue&gt;
        
        &lt;val&gt;VENKAT&lt;/val&gt;
        &lt;val&gt;vraja&lt;/val&gt;
      &lt;/KeyValue&gt;
    &lt;/record&gt;
  
  
    &lt;!-- single value record--&gt;
    &lt;record&gt;
      &lt;KeyName&gt;accountType&lt;/KeyName&gt;
      &lt;KeyValue&gt;
  
        &lt;val&gt;ADM&lt;/val&gt;
      &lt;/KeyValue&gt;
    &lt;/record&gt;
  &lt;/recordset&gt;
  </code></pre>
  <p>this is my equivalent c# class for the xml.</p>
  <pre><code>public class Record
  {
      public string KeyName { get; set; }
      public KeyValue KeyValue { get; set; }
  }
  
  public class Recordset
  {
      public List&lt;Record&gt; Record { get; set; }
  }
  </code></pre>
  <p>Now using fluent validation I am trying to validate every record in my record set.</p>
  <p>SchemaValidator.cs</p>
  <pre><code>public class SchemaValidator : AbstractValidator&lt;Entity.EigenData.Recordset&gt;
  {
      public SchemaValidator()
      {
          RuleFor(rec =&gt; rec.Record[0]).NotNull().SetValidator(new RecordValidator());
      }
  }
  </code></pre>
  <p>RecordValidator.cs</p>
  <pre><code>public class RecordValidator : AbstractValidator&lt;Entity.EigenData.Record&gt;
  {
      public RecordValidator()
      {
          RuleFor(rec =&gt; rec.KeyName).NotNull();
          RuleFor(rec =&gt; rec.KeyValue).NotNull();
      }
  }
  </code></pre>
  <p>note :I am able to validate only first record</p>
  <p>ie., <code>RuleFor(rec =&gt; rec.Record[0]).NotNull().SetValidator(new RecordValidator());</code></p>
  <p>How will I validate for all records in the recordset?
  I tried
  <code>RuleFor(rec =&gt; rec.Record).NotNull().SetValidator(new RecordValidator());</code>
  but got conversion error</p>
  <p>Program.cs</p>
  <pre><code> //Note: Recordset contains many List&lt;record&gt;
   private static void Validate(Entity.EigenData.Recordset recordset)
   {
       SchemaValidator validator = new SchemaValidator();
  
       ValidationResult results = validator.Validate(recordset);
  
       if (!results.IsValid)
       {
           foreach (var failure in results.Errors)
           {
               Console.WriteLine(&quot;Property &quot; + failure.PropertyName + &quot; failed validation. Error was: &quot; + failure.ErrorMessage);
           }
       }
       // throw new NotImplementedException();
   }
  </code></pre>