cardinal

Values and expressions

cardinal_format handles numbers, dates and zones. cardinal_expr runs depends_on, rules and conditions.

cardinal_format

Every value crosses the wire in one canonical form, and cardinal_format converts between that form and what a user sees.

HandlesDetails
RoundingExact decimals, never floats
Number formatsThe 11 formats System Settings offers, such as #,###.## and #,##,###.##
Dates and times6 date formats and 2 time formats, with strict input parsing
ZonesUTC to a zone and back, on a tz database bundled into the crate
DurationsDuration fields
Wire formsDecimals as strings ("1250.00"), dates as "2026-03-08", datetimes in UTC
CronThe next run of a cron expression in a zone, for Scheduled Job Types

The crate never reads the OS zoneinfo or TZDIR. The clock, zone and locale settings arrive as arguments. Elixir calls it through the NIF, the desk through WASM, and the template and sheet crates link it.

cardinal_expr

The expression language for depends_on, row rules, workflow and notification conditions, and automation inputs. Sources look like JavaScript and are type-checked against the Record's fields when the RecType compiles.

doc.status == "Open" && doc.qty > 0
["Draft", "Open"].includes(doc.status)
if doc.grand_total > 50000 then "High" else "Normal"
date_diff(doc.due_date, today()) < 7
RuleBehaviour
NullEquals only null. Arithmetic on null gives null. < and > with a null side are false
is_set(x)False for null, "" and an empty table. True for 0 and false
ListsAn array literal only appears as [...].includes(x)
Division by zeroAn evaluation error, division_by_zero
Depth50 nesting levels at most. Test one field against many values with includes, not 50 || clauses
StepsEvaluation stops at 100,000 steps
roundTies to even, 0 to 28 places
if c then a else bEvaluates only the branch it takes

Functions include min, max, abs, round, floor, ceil, date_diff, add_days, add_months, month_start, month_end, today() and has_role. Each gives null when an argument is null.

Compile modeReadsUsed by
compiledoc.<field>RecType expressions, also in the browser
compile_ruleAlso <set>().includes(x), a principal's setRow rules and role rules, server only
compile_with_stepsAlso steps.<node>.<output>Automation inputs
compile_scopeBare names, such as gross_payFormulas over a caller's scope, such as salary components

cardinal_meta compiles every expression in a RecType. cardinal_perm walks the expression tree to push row rules down into SQL.

On this page