Çağatay Sel (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=63e2e8f...
) *updated* an issue
Hibernate Validator (
https://hibernate.atlassian.net/browse/HV?atlOrigin=eyJpIjoiMDAyYTBlMzg2O...
) / Bug (
https://hibernate.atlassian.net/browse/HV-1958?atlOrigin=eyJpIjoiMDAyYTBl...
) HV-1958 (
https://hibernate.atlassian.net/browse/HV-1958?atlOrigin=eyJpIjoiMDAyYTBl...
) ValidatorImpl ignore nodeName passed from ValueExtractor and does not add to
propertyPath of ConstraintViolationExceptions (
https://hibernate.atlassian.net/browse/HV-1958?atlOrigin=eyJpIjoiMDAyYTBl...
)
Change By: Ç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:
{noformat}public class NeedHelpValueExtractor MyWrapperObjectExtractor implements
ValueExtractor<MyWrapperObject<@ExtractedValue ?>> {
@Override
public void extractValues(MyWrapperObject<?> myWrapperObject,
ValueExtractor.ValueReceiver receiver) {
receiver.value("data", myWrapperObject.getData());
}
}{noformat}
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. This
cascadedValueContext is being used to construct ConstraintViolationExceptions further down
the method chain.
!image-20230713-141212.png|width=1251,height=539!
(
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#100232- sha1:33a7c72 )