Hibernate-validator Groups with Spring MVC

前端 未结 3 1078
慢半拍i
慢半拍i 2020-12-20 03:42

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

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-20 03:45

    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.

提交回复
热议问题