Validation groups in Spring MVC
All constraints in Bean Validation may be added to one or more groups via groups attribute. This allows you to restrict the set of constraints applied during validation. It can be handy in cases where some groups should be validated before others like e.g. in wizards. As of Spring MVC 3.1, automatic validation utilizing validation groups is possible with org.springframework.validation.annotation.Validated annotation. In this article I will use simple Spring MVC application to demonstrate how easily you can use validation groups to validate Spring’s MVC model attributes. Form Let’s start with the form class that will be validated in steps. Firstly, we define interfaces that represents constraint groups: public class Account implements PasswordAware { interface ValidationStepOne { // validation group marker interface } interface ValidationStepTwo { // validation group marker interface } } Validation contraints Next we assign constra...