I am using Hibernate Validations. If we pass several groups to validate() the order of the validation message is random. If two validations are applied to one field and both fail and those two validations belong to two different groups. is there any way to keep the order of the validations?
// Bean
public class Register {
@Size(min = 8, max = 50, message = "Minimum should be 5 and maximum should be 10", groups=Second.class)
public String username;
@Size(min = 8, max = 50, message = "Minimum should be 5 and maximum should be 10", groups=Second.class)
@Pattern(regexp = "(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]*", message = "incorrect format", groups=First.class)
public String password;
}
// Validate call
Set<ConstraintViolation<T>> constraintViolations = validator.validate(o, First.class, Second.class);
the input is
username "test", password "test"
then all validation fails which is desired but for the password the order of the validation messages are random. I want the validation message of the First group should always appear first.