-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
Taking a shot in the dark as it looks like this library may be unsupported.
The jsonLogic library has the ability to add custom operations: https://jsonlogic.com/add_operation.html
This is needed for things like String.includes. Unfortunately, This library has no way to tap into those as it currently stands. So doing the below fails:
import jsonLogic from 'json-logic-js';
import jsToJsonLogic from 'js-to-json-logic';
jsonLogic.add_operation('includes', (a, b) => a.includes(b));
const logicStr = jsToJsonLogic(`pie.filling includes 'sug'`); // this blows upwhereas this works as expected:
import jsonLogic from 'json-logic-js';
import jsToJsonLogic from 'js-to-json-logic';
jsonLogic.add_operation('includes', (a, b) => a.includes(b));
const data = { temp: 100, pie: { filling: 'apples and sugar' } };
console.log(
jsonLogic.apply({ includes: [{ var: 'pie.filling' }, 'sug'] }, data) // results in boolean true
);Metadata
Metadata
Assignees
Labels
No labels