title: how to create a ConstraintValidator for List
body: <p>I have a simple validator to validate that a String value is part of a predefined list: </p>
  
  <pre><code>public class CoBoundedStringConstraints implements ConstraintValidator&lt;CoBoundedString, String&gt;
  {
  
  private List&lt;String&gt; m_boundedTo;
  
  @Override
  public void initialize(CoBoundedString annotation)
  {
      m_boundedTo = FunctorUtils.transform(annotation.value(), new ToLowerCase());
  }
  
  @Override
  public boolean isValid(String value, ConstraintValidatorContext context)
  {
      if (value == null )
      {
          return true; 
      }
  
      context.disableDefaultConstraintViolation();
      context.buildConstraintViolationWithTemplate("should be one of " + m_boundedTo).addConstraintViolation();
      return m_boundedTo.contains(value.toLowerCase());
  }
  
  }
  </code></pre>
  
  <p>For example it will Validate:</p>
  
  <pre><code>@CoBoundedString({"a","b" })
  public String operations;
  </code></pre>
  
  <p>I want to create a validator For a list of Strings to validate something like this:</p>
  
  <pre><code>@CoBoundedString({"a","b" })
  public List&lt;String&gt; operations = new ArrayList&lt;String&gt;();
  </code></pre>
  
  <p>I tried this:</p>
  
  <pre><code>public class CoBoundedStringListConstraints implements ConstraintValidator&lt;CoBoundedString, List&lt;String&gt;&gt;
  {
  
  private CoBoundedString m_annotation;
  
  @Override
  public void initialize(CoBoundedString annotation)
  {
      m_annotation = annotation;
  }
  
  @Override
  public boolean isValid(List&lt;String&gt; value, ConstraintValidatorContext context)
  {
      if (value == null )
      {
          return true; 
      }
  
      CoBoundedStringConstraints constraints = new CoBoundedStringConstraints();
      constraints.initialize(m_annotation);
      for (String string : value)
      {
          if (!constraints.isValid(string, context))
          {
              return false;
          }
      }
      return true;
  }
  
  }
  </code></pre>
  
  <p>The problem is, if list contains 2 or more illeagal values, there will be only one (the first one) constraint violation. I want it to have more than one. How should I do that?</p>