What is the idea of using groups in short? For example, the class definition has no groups now. What's going to change if we enable groups below?
// @Size(min = 4, max = 30, groups = LengthGroup.class)
@Size(min = 4, max = 30)
private String name;
// @Size(min = 12, max = 120, groups = LengthGroup.class)
@Size(min = 12, max = 120)
private String address;
// @Size(min = 5, max = 30, groups = LengthGroup.class)
@Size(min = 5, max = 30)
@EmailAddress//(groups = EmailGroup.class)
private String email;
p.s. there are also two corresponding interfaces for those groups
It is often useful to declare the same constraint more than once to the same target, with different properties. That's what the group is about. Consider this example:
In this example, both constraints apply to the zipcode field but with different groups and with different error messages.
Example taken from here.