UNPKG

@soeasily/rules

Version:

Evaluate and validate SoEasily DSL rules in TypeScript/JavaScript.

8 lines (7 loc) 287 B
export function evaluateRule(rule, input) { if ('expr' in rule) { const condition = new Function('input', `return ${rule.expr}`)(input); return condition ? { matched: true, event: rule.event ?? rule.then } : { matched: false }; } return { matched: false }; }