I have a class:
@ColumnNameUnique(groups = CreateTableChecks.class)
public class Table {
@Valid
@NotEmpty(groups = CreateTableChecks.class)
p
You need to use @GroupSequence
and re-define the default group sequence. Without this the validation order within a group is not defined and it can be in any order (that the class level constraint in your case is always executed first is not a must). Something like this should work:
@GroupSequence({FieldChecks.class, ClassChecks.class})
@ColumnNameUnique(groups = ClassChecks.class)
public class Table {
@Valid
@NotEmpty(groups = FieldChecks.class)
private List measures;
}
Now, if the @Default
group gets validated, first the class level constraints and then the field level ones will be validated.