I can see the javax validator returning a non null list of constraints. But that list contains 0 elements.
How can that be ?
It flies in the face of my test coverage.
Assuming you mean any of the various validate()
, validateValue()
etc. methods on Validator
, returning an empty set of ConstraintViolation
is the indicator that the requested validation was successful, i.e. no constraints were violated.
Returning an empty collection instead of null is a common best practice to avoid NullPointerException
s on the caller's side. Check isEmpty()
on the returned set to find out whether the validation was successful or not.