Class NotMandatoryOnOtherFieldValueConstraint

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

public class NotMandatoryOnOtherFieldValueConstraint extends BundledConstraint implements Constraint<Object>, ConstraintOnNull
Constraint that sets mandatory the field it is defined on if the parameter mandatoringField field has a different value than the mandatoringValue parameter.

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: constraint.com.apgar.common.lib.constraint.NotMandatoryOnOtherFieldValueConstraint Field '{0}' is mandatory when field '{1}' does not equal '{2}'
  • text.properties: constraint.com.apgar.common.lib.constraint.NotMandatoryOnOtherFieldValueConstraint Field '{0}' is mandatory when field '{0}' does not equal '{1}'

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

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.NotMandatoryOnOtherFieldValueConstraint">
                 <mandatoringField>./field</mandatoringField>
                 <mandatoringValue>value</mandatoringValue>
             </osd:constraint>
             </osd:otherFacets>
         </xs:appinfo>
     </xs:annotation>
 </xs:element>
 
Author:
APGAR Consulting