There's a bean validation in a project's jar which validation.xml contains field-level validation of Address bean.
The other project uses Address class and needs to have specific Address validation. So extended-validation.xml was created with class-level validation of Address bean.
As a result, during the app deployment, ValidationException occures: javax.validation.ValidationException: my.base.datatypes.Address has already be configured in xml.
.
Here are two validation xml files with basic validation and "extended validation".
validation.xml
<bean class="my.base.datatypes.Address" ignore-annotations="true">
<getter name="country">
<constraint annotation="my.imp.services.validation.ValidCode">
<message>{msg01}</message>
<groups>
<value>my.imp.services.validation.ImportGroup</value>
</groups>
<element name="name">Country</element>
</constraint>
</getter>
</bean>
extended-validation.xml
<bean class="my.base.datatypes.Address" ignore-annotations="true">
<class ignore-annotations="true">
<constraint annotation="my.extended.imp.services.validation.ValidAddress">
<message>ERROR DURING ADDRESS VALIDATION</message>
<groups>
<value>my.imp.services.validation.ImportGroup</value>
</groups>
</constraint>
</class>
</bean>
Is it possible to extend already existing validation?
The solution appears to be very simple and trivial. If you want to extend validation rules, use different validator which will load extended-validation.xml
constraints configuration. In this case, base validator validates data according to validation.xml
config, and another validator validates data according to extended-validation.xml
config. So no more config collisions occur.