Çağatay Sel (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=63e2e8f...
) *created* an issue
Hibernate Validator (
https://hibernate.atlassian.net/browse/HV?atlOrigin=eyJpIjoiMTgwMmIwMjk1N...
) / Bug (
https://hibernate.atlassian.net/browse/HV-1958?atlOrigin=eyJpIjoiMTgwMmIw...
) HV-1958 (
https://hibernate.atlassian.net/browse/HV-1958?atlOrigin=eyJpIjoiMTgwMmIw...
) ValidatorImpl ignore nodeName passed from ValueExtractor and does not add to
propertyPath of ConstraintViolationExceptions (
https://hibernate.atlassian.net/browse/HV-1958?atlOrigin=eyJpIjoiMTgwMmIw...
)
Issue Type: Bug Affects Versions: 8.0.0.Final Assignee: Unassigned Attachments:
image-20230713-141212.png Components: validators Created: 13/Jul/2023 07:12 AM
Environment: hibernate-validator-8.0.0-Final
Labels: validation Priority: Major Reporter: Çağatay Sel (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=63e2e8f...
)
I’ve a custom ValueExtractor for a wrapper object that keeps data in “data” property as
follows:
public class NeedHelpValueExtractor implements
ValueExtractor<MyWrapperObject<@ExtractedValue ?>> {
@Override
public void extractValues(MyWrapperObject<?> myWrapperObject,
ValueExtractor.ValueReceiver receiver) {
receiver.value("data", myWrapperObject.getData());
}
}
I’m passing the nodeName parameter as “data” which is the name of the attribute in
MyWrapperObject that gets validated. I’m able to do the validation with the above
configuration as long as there are not any constraint violation. When a constraint
violation occurs I get this exception:
JSR-303 validated property 'myTestAttribute' does not have a corresponding
accessor for Spring data binding
When i debugged the SpringValidatorAdapter.java, I’ve noticed that the
ConstraintViolationException has the wrong path and it does not contain the nodeName
“data” that I’ve passed in ValueExtractor. Correct patch should be “data.myTestAttribute”
but since it is passed as “myTestAttribute” it can’t be accessed from the wrapper object.
When I further debugged, I’ve noticed that ValidatorImply.java is not using the nodeName
while building BeanValueContext which can be seen from the below image.
(
https://hibernate.atlassian.net/rest/api/3/attachment/content/50500 )
(
https://hibernate.atlassian.net/browse/HV-1958#add-comment?atlOrigin=eyJp...
) Add Comment (
https://hibernate.atlassian.net/browse/HV-1958#add-comment?atlOrigin=eyJp...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100231- sha1:2991753 )