title: Validation of List<string> via regex in model annotation
body: <p>I'm working with asp.net mvc 5. I have a <code>List&lt;string&gt;</code> like this:</p>
  
  <pre><code>var animals = new List&lt;string&gt;
  {
     "Dog",
     "Cat"
  };
  </code></pre>
  
  <p><code>animals</code> can contain only 2 values: <code>Dog</code> and <code>Cat</code>. So, that's invalid if the value is <code>Tiger</code> or <code>Lion</code>.</p>
  
  <p>Here is the basic way I've used to validate:</p>
  
  <pre><code>var regex = new Regex(@"Dog|Cat");
  foreach (string animal in animals)
  {
     if (!regex.IsMatch(animal))
     {
        // throw error message here...
     }
  }
  </code></pre>
  
  <p>Now, I want to declare a model <code>Animal</code> to store the List:</p>
  
  <pre><code>class Animal
  {
     //[RegularExpression(@"Dog|Cat", ErrorMessage = "Invalid animal")]
     public List&lt;string&gt; Animals { get; set; }
  }
  </code></pre>
  
  <p>and in some action:</p>
  
  <pre><code>public ActionResult Add(Animal model)
  {
     if (ModelState.IsValid)
     {
        // do stuff...
     }
     // throw error message...
  }
  </code></pre>
  
  <p>So, my question is: how to use regex to validate the value of <code>List&lt;string&gt;</code> in this case?</p>