Using Conditional Validation Rules

The base product provides a form rule that performs validation based on form line configuration. The rule Form Line Configuration Validation (C1-ChkReqSectionsLines) checks for form sections, groups and lines that are marked as required. It also checks for valid values in form lines configured as foreign key references, lookups or extendable lookups. However, there are many business rules with validation that is conditional based on the values of other form lines in the form. The base product provides a Form Rule BO that is designed handle a large range of conditional validation, C1-CondElementValidation.

The Conditional Element Validation BO allows a business user to define a series of conditions that apply to sections and lines of a form. The conditions are defined as basic mathematical expressions that have a result of true or false. Your implementation should consider using this rule BO when defining a rule that validates a form line value in relation to other supporting lines on the form.

The following topics highlight some of the available features for conditional expressions. Other mathematical operators and functions are supported but these are not normally used for calculations that are common to forms validation.

Variables

Variable identifiers must be a character between a-z except x. Variable x is always used to refer to the form line that this rule applies to. Variable identifiers are case sensitive.

Operators

The following types of expression operators are supported.

Mathematical Operators
Operators of *, /, %, +, - are allowed. Examples of expression using these operators are:
  • x = a + b + c where the value of x should equal the sum of the values a, b and c

  • x = a * r where r is a rate factor variable

Comparison Operators
Operators of =, != (not equal), <, >, <= and >= are allowed. Examples of expression using these operators are:
  • x > a where the value of x should be greater than the value of a

  • x != 0 where x must have a non-zero value

Grouping Operators
Parentheses may be used to formulate expressions with sub-computations. An example of an expression using grouping is:
  • x = (a + b) / c where the value of x should be equal to the result of adding values a and b then dividing by the value of c

Functions

The following examples show the use of the most common supported functions:

Ceiling
x = ceiling (a* b) where x should equal the result of multiplying the value of a by the value of b and rounding up to the nearest whole number
Floor
x = floor (a* b) where x should equal the result of multiplying the value of a by the value of b and rounding down to the nearest whole number
Round
x = round (a* b) where x should equal the result of multiplying the value of a by the value of b and rounding the nearest whole number. A result of 1.5 would round to 2 and a result of 1.4 would round to 1. To round to a decimal place, use x = round (a* b, n) where n is the number of decimal places. The default rounding behavior is to round .5 up (ROUND_​HALF_​UP). The syntax supports overriding this behavior, for example: x = round (a* b, 2, ‘ROUND_​HALF_​DOWN'). The rounding modes supported are based on those supported for the BigDecimal java class.
Any
any [value in a | value !=''] where a is a value from a repeating line and the condition is true if any of the values of a are not blank
All
all [value in a | value !=''] where a is a value from a repeating line and the condition is true if none of the values of a are blank

Conditional Sections and Groups

The base product provides another form rule that performs conditional validation for Sections and Lines. The rule Check Conditionally Required Sections and Groups (C1-CheckCondReqdSectionGroup) checks whether or not a form section or group are required or must be empty based on a defined set of conditions. This rule can be used in conjunction with the Conditional Element Validation rule described above.

Fastpath: Refer to the Apply Rule algorithm (C1-CRQ-APRL) description for more information.