I\'m using hibernate-validator 4.3.1 and Spring MVC 3.2.3.
My application has a bean with the following properties and annotations (I\'ve removed most of them to mak
There is no more elegant way. Validating without specifying a group will validate the default groups. Hence you have to add it as described. The only other alternative is to explicitly validate all groups you are interested in via @Validated({GroupOne.class, GroupTwo.class})
. I guess it is a matter of taste what you prefer.
You can use @Valid:
public ModelAndView myMethod(@ModelAttribute @Valid MyDto myDto, BindingResult result){
if(result.hasErrors()){
....
}
if you extend your Group Interface with Default, it should take care of itself.
Like
public interface Group1 extends Default {}