Files
zen/core/expression
Ivan Miletic 13d2b84888 fix(GRL-823): list functions in ZEN expressions; negative indexes count from the end
take, takeLast, find, findLast, findIndex, findLastIndex (-1 when none),
sort and sortBy ('asc' or 'desc', stable, nulls last) and isEmpty. find,
findIndex and sortBy take a callback with # or a name given with 'as'.

items[-1] is the last item, as documented, on the stack VM and the lane
VM (a string counts from its end too); a negative index past the start is
null. The spec rows that recorded the bug, the policy spec case and its
golden now expect the value.
2026-11-27 11:21:02 +01:00
..
2026-11-17 17:37:10 +01:00
2026-11-19 18:09:09 +01:00

ZEN Expression Language

The expression language of ZEN Engine, the open-source Business Rules Engine (BRE) from GoRules.

License: MIT crates.io

ZEN expressions are readable by business users and fast enough for hot paths: a complete language for conditions, calculations and data transformation, with lexer, parser, compiler, VM, type checking and editor completions included in this crate.

use serde_json::json;
use zen_expression::evaluate_expression;

fn main() {
    let result = evaluate_expression(
        "sum(items) * multiplier",
        json!({ "items": [10, 20, 30], "multiplier": 2 }).into(),
    )
    .unwrap();
    // => 120
}

Reusable expressions compile once via compile_expression and evaluate repeatedly against different contexts.

Resources

License

MIT License