title: Difference between @Valid and @Validated in Spring
body: <p>Spring supports two different validation methods: Spring validation and JSR-303 bean validation. Both can be used by defining a Spring validator that delegates to other delegators including the bean validator. So far so good.</p>
  
  <p>But when annotating methods to actually request validation, it's another story. I can annotate like this</p>
  
  <pre><code>@RequestMapping(value = "/object", method = RequestMethod.POST)
  public @ResponseBody TestObject create(@Valid @RequestBody TestObject obj, BindingResult result) {
  </code></pre>
  
  <p>or like this</p>
  
  <pre><code>@RequestMapping(value = "/object", method = RequestMethod.POST)
  public @ResponseBody TestObject create(@Validated @RequestBody TestObject obj, BindingResult result) {
  </code></pre>
  
  <p>Here, @Valid is <a href="http://docs.oracle.com/javaee/7/api/javax/validation/Valid.html">javax.validation.Valid</a>, and @Validated is <a href="https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/validation/annotation/Validated.html">org.springframework.validation.annotation.Validated</a>. The docs for the latter say</p>
  
  <blockquote>
    <p>Variant of JSR-303's Valid, supporting the specification of validation
    groups. Designed for convenient use with Spring's JSR-303 support but
    not JSR-303 specific.</p>
  </blockquote>
  
  <p>which doesn't help much because it doesn't tell exactly how it's different. If at all. Both seem to be working pretty fine for me.</p>