That's correct. If you use @ReportAsSingleViolation you will get the error message of the composed constraint (not the error messages from the failing constraints). I just mentioned @ReportAsSingleViolation for completeness.
I also noticed that I made a mistake in my example. So here is the right version:
Code:
public class AccountBean {
@NotEmpty(groups = First.class, message = "{xxx.account.cc}")
@IsCardBannedNumber(groups = Second.class, message = "{xxx.constraints.bannedCCNumber}")
@IsValidCardNumber(groups = Third.class, message = "{xxx.account.invalidCardNumber}")
private String creditCart;
}
Code:
@GroupSequence({First.class, Second.class, Third.class})
public interface OrderedChecks {
}
Code:
Set<ConstraintViolation<Object>> constraintViolationSet = validator.validate(object, OrderedChecks.class);
As side effect you will only get a single violation if something goes wrong. If for example @IsCardBannedNumber fails the validation will terminate without evaluating @IsValidCardNumber.
Sorry about the wrong example earlier.
--Hardy