|
Initially I used method validation from Hibernate Validator 4.3.1.Final through interception.Turned out that method validation sometimes pass bad values.
After simplifying and researching I got:
-
It appears when one of param List<>
-
It appears when method is enhanced
-
it works if that param is Array, not List<>
-
checked Hibernate Validator 5 - there is no such problems
-
from debugger I saw that the issue in beanCacheManager that sometimes doesn't have constraints
Interesting thing that it works in ~half of cases. I wrote tests that performs validation for a single method with the same params 100 times. And here is the result:
I duplicate here how I used core validation method from attachments:
private Validator getValidator() {
return Validation.byProvider(HibernateValidator.class).configure().buildValidatorFactory().getValidator();
}
public Boolean validate(Object o, Method method, Object[] args) {
return getValidator().unwrap(MethodValidator.class).validateAllParameters(o, method, args).isEmpty();
}
You can see the full test code in attachments. Thanks.
|