Jan 27th, 2010, 01:25 PM
Using @Valid on multiple arguments
Can you have the @Valid annotation on multiple arguments in an annotated method handler? Something like this:
public ModelView foo( @Valid @CustomAnnotation Bar arg1, BindingResult bindResultsArg1, @Valid @CustomAnnotation Bar arg2, BindingResult bindResultsArg2 )
Jan 27th, 2010, 05:07 PM
Yes, this should work. The framework loops over each argument to the handler method, looking for annotations like @RequestParam, @RequestBody, @Valid, etc. and processes them (i.e. binds request parameters to them) one at a time. The validator should be called for each argument.