ConstraintValidatorContext removes iterable nesting, bug?
by John Hendrikx
I'm currently trying to use JSR-303 validation inside a project with a
complicated hierarchical structure that needs validation. What I find
is that even in custom validators, the ConstraintValidatorContext is
limiting me in what paths I can construct to indicate the proper error
For example, when my custom rule is called as part of an iteration, and
I want to add another level of iteration in the path like so:
...it will overwrite the current iterable part of the path (allowing me
to modify the "parent" context it looks like). So instead of getting:
It removes the ["x"] and results in: root["z"].y which is clearly wrong.
If I add a dummy property node first, I can atleast see the root iterable:
Results in: root["x"].$DUMMY$["z"].y
I also think it is a shame that nested Iterables are not supported.
Hierarchical structures can have constructs like Map<String, List<X>>
and currently annotating X has no effect at all.
6 years, 10 months