Hibernate -validator group sequence provider getDefaultSequenceProvider gets null as input

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; // Getters and setters } 

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

+3
spring spring-boot hibernate-validator
Jun 13 '17 at 11:31 on
source share

No one has answered this question yet.

See similar questions:

45
JSR 303 Validation, if one field equals something, then these other fields must not be null

or similar:

226
Cross Field Validation with Hibernate Validator (JSR 303)
3
JSR-303 How to test two child objects differently
2
JSR303 - apply all validation groups defined sequentially
one
Spring Boot failed to convert JSON to pojo from mail request for fields that are not of type string
one
Spring MVC form validation does not work for nested complex types
one
(Spring, Thymeleaf) How to request a "POST" controller with a list of models inside the model?
0
Hibernate Validator @NotNull not working properly
0
Validating Shafts with Service Level Groups Using Spring
0
Spring + JSR 303 Verification Group Ignored



All Articles