Closed beeme1mr closed 10 months ago
Hi @beeme1mr,
Thank you for your bug report!
I've pushed v1.3.1
to resolve this issue in the module; I'm going to try to update the docs website & set up a cicd pipeline for it very soon.
The library used on the docs website has been updated now as well; I'll need to take the weekend to update some of the documentation & build out the pipeline, but you should be able to confirm in the sandbox now (it may require a cache reset).
Overview
There's an inconsistency between the
json-logic-js
andjson-logic-engine
when using the 'in' string operation. It appears to be undefined behavior according to https://jsonlogic.com/tests.json but the wayjson-logic-js
behaves is more in line with what I expected the results to be.Steps to reproduce
JsonLogic JS
{"in":["Spring", { "var": "city" }]}
You should see "false" as the output. Adding
{ "city": "Springfield" }
as Data and recomputing returns "true".JSON Logic Engine
{"in":["Spring", { "var": "city" }]}
You should see "true" as the output and an expected error in the dev console. Adding
{ "city": "test" }
as Data and recomputing returns "false" with no errors. Adding{ "city": "Springfield" }
as Data and recomputing returns "true".The console error is:
Summary
JSON Logic Engine isn't validating the runtime input type from user supplied context. JsonLogic tends to return a falsy value when user supplied context is invalid for a given ruleset. This is important for our use case because the people writing the rules may not be the ones defining the context.