You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HV-823 Provide contract for customization of property names in constraint violation
Added PropertyNodeNameProvider SPI with Property and JavaBeanProperty as supporting interfaces.
This SPI lives in JavaBeanHelper and is used to get the name when creating JavaBeanField and JavaBeanGetter,
so when a property path is constructed, this resolved name is used.
If not set, the default implementation will be used that returns the actual name from the class.
This new SPI can be configured through HibernateValidatorConfiguration.
Testing:
- Added tests for configuration
- Added a sample implementation by using reflection and custom annotation
- Added tests for reflection implementation
- Added a sample implementation by using Jackson lib
- Added tests for Jackson implementation
Added documentation with examples.
An SPI for registering additional constraint validators programmatically, see <<section-constraint-definition-contribution>>.
53
53
54
+
`org.hibernate.validator.spi.nodenameprovider`::
55
+
An SPI that can be used to alter how the names of properties will be resolved when the property path is constructed. See <<section-property-node-name-provider>>.
56
+
54
57
[NOTE]
55
58
====
56
59
The public packages of Hibernate Validator fall into two categories: while the actual API parts are
@@ -759,4 +762,94 @@ It is important to mention that in cases where programmatic constraints are adde
759
762
`HibernateValidatorConfiguration#addMapping(ConstraintMapping)`, adding mappings should
760
763
always be done after the required getter property selection strategy is configured.
761
764
Otherwise, the default strategy will be used for the mappings added before defining the strategy.
762
-
====
765
+
====
766
+
767
+
[[section-property-node-name-provider]]
768
+
==== Changing the way property names are resolved when the property path is constructed
769
+
770
+
Imagine that we have a simple data class that has `@NotNull` constraints on some fields:
0 commit comments