Rule Formula validation
Formula parsing
- There must be an equal number of “(“ and “)” brackets in the Rule.
- Only the operands “EQ”, “=”, “NE”, “<>”, “><” are valid for String values (i.e. GT or LT are not valid).
- All expressions are enclosed in brackets and all option codes as well as keywords are stored in upper case.
Formula validation
- The Option must be defined in the Options table
- The Value must be valid for the specified Data Type (i.e. String: ‘xxx’, Integer: 999, Float: 9999999.99, Date/Time: ’yyyymmdd’).
- If a range has been defined for that Option then the Value must be within the range.
- [After OK5R3] If any ‘allowed values’ have been defined for that Option then the Values must be within the Allowed Values table for that Option. This also applies for a list of Values in the “IN (‘xxx’, ‘abc’, ‘def’)” expression.
- If the Option allows multiple values then a rule formula with the “=” operator is rewritten using the “IN” operator because multi-value options are evaluated using the “IN” operator. In canonical text the Rule grammar specifies that an “IN” expression must start with the value, then the operator and then the Option or Option Value list, i.e. “Value IN Option”.
Formula translation
The original formula defining the Rule is stored as a text field, but is changed into a canonical format (reduced to consistent operators), in order to optimise system performance and any future validation and parsing requirements.
For example, “ABS= ‘Yes’ & EngineSize EQ 1300”
is stored as “(ABS= ‘Yes’) AND (ENGINESIZE = 1300)”.
Valid characters are replaced as follows.
|
|
EQ, =
|
=
|
LE, <=, =<
|
<=
|
LT, <
|
<
|
GT, >
|
>
|
GE, =>, >=
|
>=
|
NE, ><, <>, !=
|
<>
|
IN
|
IN
|
AND, &
|
AND
|
OR, |
|
OR
|
SPECIFIED
|
SPECIFIED
|
NOT
|
NOT
|
The “compiled” formula is stored in a special format for easy and quick referencing to the Options and, if defined, Allowed Values contained within the formula. This reduces the need to interpret the formula every time it is used.
Conventions
- Partial string evaluation (using wild cards) is not possible.
- The values are not case-sensitive.
© 2016 Pragma