Jamie Lawrence

wombat-rules

A type-safe TypeScript wrapper around JSONLogic for evaluating business rules at the edge.

Source on GitHub ↗

Built with: TypeScript · JSONLogic · Cloudflare Workers

A small library that wraps json-logic-js with the utilities you actually need before running rules in production: evaluate a rule against data, analyse which data keys a rule depends on, and validate that a rule can execute with the data you have — before you run it.

const rule = { "==": [{ "var": "user.age" }, 18] };
const data = { user: { age: 18 } };

evaluateRule(rule, data);      // true
getRequiredKeys(rule);         // ['user.age']
canExecuteRule(rule, data);    // true

It’s aimed at edge environments — feature flags, dynamic permissions, conditional workflows — anywhere you want rules stored as data and evaluated cheaply in a Cloudflare Worker.

How it was built

TypeScript with full type definitions and effectively one dependency (JSONLogic itself), designed to keep the footprint small enough for edge deployment. The dependency-analysis piece walks the rule AST to extract every var reference, which is what makes the pre-flight canExecuteRule check possible. It was built as the rules engine for the Wombatmode experiment.