Open
Description
The docs gives an example of documenting constraints:
public void example() {
ConstraintDescriptions userConstraints = new ConstraintDescriptions(UserInput.class);
List<String> descriptions = userConstraints.descriptionsForProperty("name");
}
static class UserInput {
@NotNull
@Size(min = 1)
String name;
@NotNull
@Size(min = 8)
String password;
}
This way, you get all constraints descriptions for one property, but when using validation groups, how to get only the constraints descriptions for the given group? For example:
public void example() {
ConstraintDescriptions userConstraints = new ConstraintDescriptions(UserInput.class);
List<String> descriptions = userConstraints.descriptionsForProperty("email").groups(OnCreate.class);
}
static class UserInput {
@NotNull
String name;
@NotNull(groups = OnCreate.class)
@Null(groups = OnEdit.class)
String email;
}