You can validate properties that are interrelated to ensure that they are consistent. To do this, use the PropertyGatherer validator, which can gather up named properties in a Map<String, Object> and then invokes a configured BeanValidator for inter-property validation. For example, this AllSameValuesValidator will have its validateBean method invoked with the pBean parameter being Map<String, Object> containing entries for StringOne and StringTwo:

<schema id="cross-props">
  <bean class="atg.service.configuration.db.TestBean"/>
  <wrapping-validator-instance class="PropertyGatherer">
    <param name="propertiesValidator" value="instance:atg.service.payloadschema.
        PayloadSchemaRegistryTest$AllSameValuesValidator"/>
    <param name="propertyNames" value="stringOne,stringTwo"/>
  </wrapping-validator-instance>
  <property name="stringOne" required="true"/>
  <property name="stringTwo" required="true"/>
</schema>

The PropertyGatherer has other properties that can be configured using the param tag:

Property

Description

continueDespiteIndividualErrors

A Boolean property that defaults to false and prevents inter-property validation from occurring if one of the individual property validators flags a validation error

propertiesValidator

A BeanValidator property that specifies the BeanValidator to be invoked for inter-property validation. Note that validataeBean is the only bean to be invoked for this BeanValidator.

maxDepth and minDepth

Integer properties that represent the maximum and minimum ValidatorContext ancestor stack depth at which property values are collected. If property values are not being collected as expected, turn on loggingDebug on the PropertyGatherers. The default for these properties is set to 1.

remappedPropertyNames

A Map <String,String> property that can be configured to store one encountered property name to a different map key.

saveMultipleValues

A Boolean property that saves multiple values for the same property name when set to true. In this case, the map passed to the propertiesValidator BeanValidator is a Map <String, List <Object>> where the value is a list of values seen for that property name. By default, this property is set to false.


Copyright © 1997, 2017 Oracle and/or its affiliates. All rights reserved. Legal Notices