Expression Syntax Reference
Logic block expressions define validation rules that evaluate against extracted document data. This page covers all supported syntax.
Field References
Section titled “Field References”Reference extracted field values using the $ prefix followed by the field name:
$invoice_number$total_amount$vendor_nameField names must exactly match the names defined in the Processor. Use snake_case naming.
For fields inside a group, use the same $field_name syntax — the expression context determines which group instance is being evaluated.
Literals
Section titled “Literals”Strings
Section titled “Strings”String values for comparison:
$vendor_name = "Acme Corp"$status != ""Numbers
Section titled “Numbers”Numeric literals (integer or decimal):
$total_amount > 0abs($expected - $actual) < 0.01$tax_rate = 8.25Dates are represented as Unix timestamps in milliseconds:
$invoice_date > 1719806400000The value 1719806400000 represents July 1, 2024. The expression builder provides a date picker that converts selected dates to timestamps automatically.
Operators
Section titled “Operators”Arithmetic
Section titled “Arithmetic”| Operator | Description | Example |
|---|---|---|
+ |
Addition | $subtotal + $tax |
- |
Subtraction | $expected - $actual |
* |
Multiplication | $unit_price * $quantity |
/ |
Division | $total / $count |
^ |
Exponentiation | $base ^ 2 |
Comparison
Section titled “Comparison”| Operator | Description | Example |
|---|---|---|
= |
Equal to | $status = "approved" |
!= |
Not equal to | $vendor_name != "" |
> |
Greater than | $total_amount > 0 |
< |
Less than | $discount < 100 |
>= |
Greater than or equal | $quantity >= 1 |
<= |
Less than or equal | $tax_rate <= 10 |
Logical
Section titled “Logical”| Operator | Description | Example |
|---|---|---|
and |
Both conditions must be true | $total > 0 and $date > 1719806400000 |
or |
At least one condition must be true | $status = "approved" or $status = "pending" |
not |
Negates the following condition | not $is_void |
Grouping
Section titled “Grouping”Use parentheses to control evaluation order:
($subtotal + $tax) = $total_amount($status = "approved" or $status = "pending") and $total > 0Functions
Section titled “Functions”Math Functions
Section titled “Math Functions”| Function | Arguments | Returns | Description |
|---|---|---|---|
abs(number) |
1 number | number | Absolute value |
ceil(number) |
1 number | number | Round up to nearest integer |
floor(number) |
1 number | number | Round down to nearest integer |
round(number) |
1 number | number | Round to nearest integer |
sqrt(number) |
1 number | number | Square root |
Comparison Functions
Section titled “Comparison Functions”| Function | Arguments | Returns | Description |
|---|---|---|---|
max(number, number) |
2 numbers | number | Larger of two values |
min(number, number) |
2 numbers | number | Smaller of two values |
fuzzyEquals(string, string) |
2 strings | boolean | Fuzzy string comparison — returns true if strings are approximately equal |
Conditional Functions
Section titled “Conditional Functions”| Function | Arguments | Returns | Description |
|---|---|---|---|
if(condition, true_value, false_value) |
condition + 2 values | any | Returns true_value if condition is truthy, otherwise false_value |
Lookup Functions
Section titled “Lookup Functions”| Function | Arguments | Returns | Description |
|---|---|---|---|
lookup(value, constant_id, lookup_col, return_col) |
4 strings | string or number | Finds value in lookup_col of the specified Constant, returns the corresponding return_col value. Falls back to fuzzy matching if no exact match. |
Date Functions
Section titled “Date Functions”| Function | Arguments | Returns | Description |
|---|---|---|---|
today() |
none | number | Current date/time as Unix timestamp (milliseconds) |
Aggregation Functions
Section titled “Aggregation Functions”| Function | Arguments | Returns | Description |
|---|---|---|---|
sum(number, number) |
2 numbers | number | Sum of two values |
rsum(group_field) |
1 group field name | number | Sum of a field across all instances of a repeating group |
ravg(group_field) |
1 group field name | number | Average of a field across all instances of a repeating group |
rcount(group_field) |
1 group field name | number | Count of instances in a repeating group |
The rsum, ravg, and rcount functions are designed for field groups. They aggregate across all instances of a repeating group within a single document.
Examples
Section titled “Examples”Basic field check
Section titled “Basic field check”$total_amount > 0Ensures the total amount is positive.
Non-empty field validation
Section titled “Non-empty field validation”$vendor_name != "" and $invoice_number != ""Ensures both vendor name and invoice number are populated.
Tolerance check
Section titled “Tolerance check”abs($expected - $actual) < 0.01Checks that two values are within a penny of each other.
Line item reconciliation
Section titled “Line item reconciliation”rsum($line_item_amount) = $total_amountVerifies that the sum of all line item amounts equals the document total.
Date range validation
Section titled “Date range validation”$invoice_date > 1719806400000 and $invoice_date < 1735689600000Checks that the invoice date falls between July 1, 2024 and January 1, 2025.
Compound business rule
Section titled “Compound business rule”($subtotal + $tax) = $total_amount and $total_amount > 0Validates that subtotal plus tax equals the total, and the total is positive.
Lookup against a constant
Section titled “Lookup against a constant”lookup($procedure_code, "rate_schedule", "procedure", "rate") >= $billed_amountLooks up the expected rate for a procedure code from the “rate_schedule” constant and checks that the billed amount does not exceed it.
Invoice recency check
Section titled “Invoice recency check”$invoice_date > today() - 31536000000Checks that the invoice date is within the last year (365 days in milliseconds).
Conditional tax calculation
Section titled “Conditional tax calculation”if($is_taxable, $subtotal * 1.1, $subtotal) = $total_amountApplies a 10% tax if the item is taxable, then checks the result matches the total.