spring-projects / spring-projects/spring-framework
Add support for customization of property names in validation
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 60.2k
- Forks
- 38.8k
- Avg merge
- 5d 2h
- Merged PRs (30d)
- 27
Description
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.Finalis explicitly set inbuild.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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the failing test in the linked spring-validation-custom-property-name-support project and inspect SpringValidatorAdapter in spring-context/src/main/java/org/springframework/validation/beanvalidation/SpringValidatorAdapter.java around the reported method. Trace how customized Hibernate Validator property names reach DataBinder. Done means validation with a customized property name no longer raises NotReadablePropertyException, with coverage in Spring's tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100