Skip to main content

Module evaluator

Module evaluator 

Source
Expand description

CRUDUI expression evaluator (expressions.md §5/§6/§7, JS PathResolver parity).

The shared 4-language fixture (tests/fixtures/expr/cases.json) is generated from the JS reference engine and is the §9 contract all four engines pass, so this evaluator mirrors validator-ts PathResolver function-for-function:

  • Evaluator::evaluate → bool (JS evaluateCondition): Boolean of the resolved value for Path/Literal; logical short-circuit; comparison; in; unary; a ternary is Boolean(its branch value).
  • Evaluator::evaluate_value → value (JS evaluateExpressionValue): a ternary returns its branch value; EVERYTHING else returns the boolean condition result.

truthy (JS Boolean): null/false/0/“” falsy; “0”, “false”, [], {}, and every non-empty value truthy. == / != use JS loose equality (same-type ===, else numeric when both Number()-parse, else string). > >= < <= coerce BOTH sides to number (parseFloat, NaN→0) and compare numerically — no lexicographic branch (JS compare parity).

No eval / no regex evaluation (GRAMMAR §10) — a pure AST walk.

Structs§

Evaluator
AST evaluator bound to a form-data tree and the current field path.

Functions§

is_truthy
Truthy test (JS Boolean). null/false/0/0.0/“” are falsy; “0”, “false”, empty array, empty object, and every non-empty value are truthy.
relative_base
The path that a relative path with levels_up further dots starts from: the current field is one level and each further dot moves one more level up, and a row key leaves together with the name of its collection (expressions.md, “Evaluation”).