Writing Expressions

The program includes a very powerful expression processor for validation and filtering. Here are some of the features and syntax used by that processor.

Supported Literals

  • strings - single and double quotes (e.g. “hello”, ‘hello’)

  • numbers - e.g. 103, 2.5, .5

  • dates - “2020-10-09” (yyyy-mm-dd)

Comparison Operators

operatormeaning
==equal
!=not equal
<less than
>greater than
<=less than or equal to
>=greater than or equal to

Logical Operators

  • not or !
  • and or &&
  • or or ||

String Operators

operatormeaning
+concatenation
matchesregex match
containsstring contains
startsWithhas prefix
endsWithhas suffix

Membership Operators

operatormeaning
incontain
not indoes not contain

Example:

$GROUP in ["human_resources", "marketing"]

Numeric Operators

operatormeaning
..inclusive range (e.g. 1..3 == [1, 2, 3])

Example:

$AGE in 18..45

Ternary Operators

  • $FOO ? ‘yes’ : ‘no’

Example:

$AGE > 30 ? "mature" : "immature"

Short-Circuit Evaluation

The expression processor uses short-circuit evaluation, meaning that it will stop evaluating an expression as soon as the result is known.

For example, in the expression:

$QTY != nil && $QTY > 10

if $QTY is nil (meaning there was no value supplied in that cell), the second part of the expression (where we are comparing $QTY with a number) will not be evaluated, preventing an improper comparison (nil > 10) which would have resulted in an error.

Revised: 2020-12-05