The issue is that it is not always possible to know which value is considered when traversing the path: this is typically a problem with a Set as you don't know which element of the set has been considered (with a Map or a List you have the key or the index). It might also be an issue in the case of TYPE_USE constraints. Note that introducing the value into the Path is going to have consequences on the serializability of it. See this comment of Gunnar on HipChat:
[11:10 AM] Gunnar Morling: in 5.2 we say this: [11:10 AM] Gunnar Morling:
Bean Validation implementations should ensure that a ConstraintViolation implementation is Serializable provided that the root bean, the leaf bean, the invalid value and keys in the Path object are Serializable objects.If a user wishes to send ConstraintViolation remotely, it should make sure the object graph validated is itself Serializable. |
[11:10 AM] Gunnar Morling: so this would have to be expanded for the Path object [11:11 AM] Gunnar Morling: every value along the path needs to be serializable (in case the user wishes to send remotely)
This is a follow-up of https://hibernate.atlassian.net/browse/HV-980 . It has been solved in HV by introducing a custom org.hibernate.validator.path.PropertyNode with a getValue method. |