title: Spring 3, JSR-303 (bean validation) and validating collection
body: <p>I have a simple class Foo, saying like this one :</p>
  
  <pre><code>public class Foo {
      @NotNull
      private String bar;
      public String getBar(){ return bar; }
      public void setBar(String _bar){ this.bar = _bar; }
  }
  </code></pre>
  
  <p>Now, I have a controller REST method that take an array (or collection) of Foos where I want to ensure every Foo has a non-null bar property.
  I thought using the @Valid annotation would make the trick, but it seems it isn't :</p>
  
  <pre><code>@Controller
  public class MyController {
      @RequestMapping(value="/foos", method=RequestMethod.POST)
      public @ResponseBody String createFoos(@Valid @RequestBody Foo[] foos){
          // blah blah blah
          return "yeah";
      }
  }
  </code></pre>
  
  <p>Note: It doesn't work with a List&lt;Foo&gt; either. But with a unique Foo it works !</p>
  
  <p>Looks like Spring validation doesn't work when we have "multiple" objects (in collection or array).</p>
  
  <p>I even tried to implement a HandlerMethodArgumentResolver with a custom annotation, but I don't know how to define "indexed property names" in BindingResult.</p>
  
  <p>If someone knows a workaround for this problem, it would be greatly appreciated ! :)</p>