I am using a hibernation validator group sequence and want to run groups in a sequence based on business rules. But the input for groupSequenceProvider for its getValidationGroups is always zero, and so the user sequence is never added.
My request object:
@GroupSequenceProvider(BeanSequenceProvider.class) public class MyBean { @NotEmpty private String name; @NotNull private MyType type; @NotEmpty(groups = Special.class) private String lastName;
Type of listing:
public enum MyType { FIRST, SECOND }
My custom sequence provider:
public class BeanSequenceProvider implements DefaultGroupSequenceProvider<MyBean> { @Override public List<Class<?>> getValidationGroups(MyBean object) { final List<Class<?>> classes = new ArrayList<>(); classes.add(MyBean.class); if (object != null && object.getType() == MyType.SECOND) { classes.add(Special.class); } return classes; } }
Group annotations:
public interface Special { }
When I execute the above code, I get the input MyBean object as null and cannot add a custom sequence. What am I missing? I am using the hibernate-validator version as 5.4.1. Final
spring spring-boot hibernate-validator
Q Bhat Jun 13 '17 at 11:31 on 2017-06-13 11:31
source share