Hi,
Im trying to implement both validation groups and group sequence on the same form object, but Im having a problem whereby the group sequence is being ignored.
Suppose I have defined the group sequence on my form object class as follows :
@GroupSequence({User.class, Level1.class, Level2.class}) public class User {
@Min(value = 11111,groups={Step1.class,Level2.class}) @Pattern(regexp = "[0-9]{5}",groups={Step1.class,Level1.class}) private String name;
@Size(min=1,groups=Step2.class) private String employeeId;
public String getName() { return name; }
public void setName(String name) { this.name= name; }
public String getEmployeeId() { return employeeId; }
public void setEmployeeId(String employeeId) { this.employeeId = employeeId; } }
Inside my controller class, I validate only for the Step1 group Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); ConstraintViolation<User> constraint = validator.vaidate(user,Step1.class); System.out.println(constraint.getMessage());
Suppose the User object's name field was set to "a", I would thus be expecting only the @Pattern validation to be performed, which is according to my group sequence defined. However, the constaint object returned displayed both the @Min and @Pattern errors.
Any help would be appreciated.
Thanks, Jon
|