title: spring mvc rest validation on all method parameters
body: <p>I would like to find a a way to validate a rest method based on all parameters outside the Controller. </p>
  
  <p><strong>First Question:</strong> Is there already a way to do it?</p>
  
  <p><strong>Second Question:</strong> If not - how can I hook the validation into spring mvc binding prozess.</p>
  
  <p>A way how it could look like. It would be nice to mark the method with a new <strong>@MethodValidation</strong> Annotation:</p>
  
  <pre><code>@Validate
  @MethodValidation(MyValidator.class)
  public Response doSomthing(String param1, Integer param2, Something param3){}
  </code></pre>
  
  <p>Annotation</p>
  
  <pre><code>@Target({ElementType.METHOD})
  @Retention(RetentionPolicy.RUNTIME)
  @Documented
  public @interface MethodValidation{
       Class&lt;? extends MethodValidator&lt;?, ?&gt;&gt;[] value();
  }
  </code></pre>
  
  <p>Implement a Validator</p>
  
  <pre><code>public class MyValidator implements MethodValidator{
     public void validate(Object[] params, Errors errors){
        String param1 = (String ) params[0];
        Integer param2 = (Integer) params[1];
        Something param3 = (Something)params[3];
        // .... do some validations
        if(error)
             errors.reject("Some.error.done");
     }
  }
  </code></pre>