title: How do you validate against each string in a list using Fluent Validation?
body: <p>I have an MVC3 view model defined as:</p>
  
  <pre><code>[Validator(typeof(AccountsValidator))]
  public class AccountViewModel
  {
      public List&lt;string&gt; Accounts { get; set; }
  }
  </code></pre>
  
  <p>With the validation defined using FluentValidation (v3.3.1.0) as:</p>
  
  <pre><code>public class AccountsValidator : AbstractValidator&lt;AccountViewModel&gt;
  {
      public AccountsValidator()
      {
          RuleFor(x =&gt; x.Accounts).SetCollectionValidator(new AccountValidator()); //This won't work
      }
  }
  </code></pre>
  
  <p>And the account validation would possibly be defined:</p>
  
  <pre><code>public class AccountValidator : AbstractValidator&lt;string&gt; {
      public OrderValidator() {
          RuleFor(x =&gt; x).NotNull();
          //any other validation here
      }
  }
  </code></pre>
  
  <p>I would like each account in the list to be valdiated as described in the <a href="http://fluentvalidation.codeplex.com/wikipage?title=CreatingAValidator&amp;referringTitle=Documentation&amp;ANCHOR#Collections" rel="noreferrer">documentation</a>.  However, the call to <code>SetCollectionValidator</code> doesn't work as this is not an option when using a <code>List&lt;string&gt;</code> although the option would be there if it were defined as <code>List&lt;Account&gt;</code>.  Am I missing something?  I could change my model to use <code>List&lt;Account&gt;</code> and then define an Account class but I don't really want to change my model to suit the validation.</p>
  
  <p>For reference, this is the view that I am using:</p>
  
  <pre><code>@model MvcApplication9.Models.AccountViewModel
  
  @using (Html.BeginForm())
  {
      @*The first account number is a required field.*@
      &lt;li&gt;Account number* @Html.EditorFor(m =&gt; m.Accounts[0].Account) @Html.ValidationMessageFor(m =&gt; m.Accounts[0].Account)&lt;/li&gt;
  
      for (int i = 1; i &lt; Model.Accounts.Count; i++)
      {
          &lt;li&gt;Account number @Html.EditorFor(m =&gt; m.Accounts[i].Account) @Html.ValidationMessageFor(m =&gt; m.Accounts[i].Account)&lt;/li&gt;
      }
  
      &lt;input type="submit" value="Add more..." name="add"/&gt;
      &lt;input type="submit" value="Continue" name="next"/&gt;
  }
  </code></pre>