Hibernate Validator (HV) 6.1.0.FINAL adds support for property names customization.

Simply put, this feature allows us to customize how property names are resolved during validation, so for e.g. depending on our needs private String firstName can be resolved to firstName, or first_name, or whatever we want.

This, however, causes issues to Spring, because DataBinder is not able to find a corresponding accessor if the name has changed. org.springframework.beans.NotReadablePropertyException is raised in this case. This is the method that is failing.

I have created a small project to showcase this. Some things to note: - HV 6.1.0.Final is explicitly set in build.gradle - Some configuration is needed to set up this HV feature - Project has one test that is failing with the above mentioned exception

This feature is specific for HV library, it is not (yet) part of Java Bean Validation specification, so i don't know what is Springs stand on supporting features like this, but i would assume a lot of Spring users would find feature useful.

I am willing to contribute with implementing this support if needed.

Edit: I have updated the showcase project referenced above, to use latest stable Spring version, just to show that the issue is still present.

Comment From: mjustin

From a Spring standpoint, it seems like customizing the property names in FieldError would be even more handy than just Hibernate constraint property names. That would then apply to all field errors — including Hibernate ones, manually created ones, etc.

Comment From: subnetmarco

Any updates on this issue?

Comment From: Hollerweger

My main issue is that the FieldErrorsas part of MethodArgumentNotValidExceptionare returning the Class field name in getField() instead of the Jackson name part of @JsonProperty. This way the wrong field name is returned in the response to the client (eg.: camelCase instead of burger-case). Second issue is that Spring ViolationFieldErroris private and there is no easy way to access the ConstrainViolationwith the rootBean to parse the annotations my self. Would this proposal allow to return name as defined in @JsonProperty?