jsr349

How to validate field level constraint before class level constraint?

人走茶凉 提交于 2019-12-19 04:15:15
问题 I have a class: @ColumnNameUnique(groups = CreateTableChecks.class) public class Table { @Valid @NotEmpty(groups = CreateTableChecks.class) private List<Measure> measures; } The class level constraint @ColumnNameUnique(groups = CreateTableChecks.class) always runs first, after that the field level constraint @NotEmpty(groups = CreateTableChecks.class) runs. Is there anyway to force the the field level constraint @NotEmpty(groups = CreateTableChecks.class) runs first? 回答1: You need to use

How to validate field level constraint before class level constraint?

偶尔善良 提交于 2019-12-01 00:45:19
I have a class: @ColumnNameUnique(groups = CreateTableChecks.class) public class Table { @Valid @NotEmpty(groups = CreateTableChecks.class) private List<Measure> measures; } The class level constraint @ColumnNameUnique(groups = CreateTableChecks.class) always runs first, after that the field level constraint @NotEmpty(groups = CreateTableChecks.class) runs. Is there anyway to force the the field level constraint @NotEmpty(groups = CreateTableChecks.class) runs first? You need to use @GroupSequence and re-define the default group sequence . Without this the validation order within a group is