JSR Bean Validation and Multiple Groups, And Against OR

Someone is faced with the need to have a restriction that applies only when all group offers are satisfied. In other words, for

@NotNull(groups= {Group1.class, Group2.class}) private Integer value; 

An invalid restriction applies when any group is valid.

What if I want to apply a restriction when both groups are valid?

Having a custom group is not an option, as there are many combinations of such groups in my application.

+4
source share
1 answer

You can declare a group sequence containing all of your groups and confirm this sequence.

+3
source

Source: https://habr.com/ru/post/1401860/


All Articles