Class MandatoryOnOtherFieldValueOtherwiseEmptyConstraint

java.lang.Object
com.apgar.common.lib.constraint.BundledConstraint
com.apgar.common.lib.constraint.MandatoryOnOtherFieldValueOtherwiseEmptyConstraint
All Implemented Interfaces:
Constraint<Object>, ConstraintOnNull, JavaBeanVersion

public class MandatoryOnOtherFieldValueOtherwiseEmptyConstraint extends BundledConstraint implements Constraint<Object>, ConstraintOnNull
Constraint that sets mandatory the field it is defined on if the parameter mandatoringField has the same value as the mandatoringValue parameter, otherwise it should be empty.

Supported types: string, int, integer, decimal, boolean

The error message and/or information message created in the error.properties and text.properties files respectively will be displayed if the constraint is not verified.

  • error.properties to be set: constraint.com.apgar.common.lib.constraint.MandatoryOnOtherFieldValueOtherwiseEmptyConstraint Field '{0}' is mandatory when field '{1}' = '{2}', empty otherwise
  • text.properties to be set: constraint.com.apgar.common.lib.constraint.MandatoryOnOtherFieldValueOtherwiseEmptyConstraint Field '{0}' is mandatory when field '{1}' = '{2}', empty otherwise

This constraint is defined in the XSD under the field and takes for argument the path of the second mandatoring field and the mandatoring value.

 <xs:element name="sampleField" minOccurs="0" maxOccurs="1">
     <xs:annotation>
         <xs:documentation xml:lang="en-US">
             <osd:label>Sample Field</osd:label>
         </xs:documentation>
         <xs:appinfo>
             <osd:otherFacets>
             <osd:constraint class="com.apgar.common.lib.constraint.MandatoryOnOtherFieldValueOtherwiseEmptyConstraint">
                 <mandatoringField>./field</mandatoringField>
                 <mandatoringValue>value</mandatoringValue>
             </osd:constraint>
             </osd:otherFacets>
         </xs:appinfo>
     </xs:annotation>
 </xs:element>
 
Author:
APGAR Consulting