json-logic-ruby icon indicating copy to clipboard operation
json-logic-ruby copied to clipboard

fix: Fix uses_data to resolve var arrays correctly

Open arushs opened this issue 2 years ago • 0 comments

There is a bug within uses_data. It takes only the first value for var values. It should take all. Consider the below example

```
{
  "all" => [
    { "var"=> "a" },
    { "var"=> ["b", "c"] }
  ],
}
```
Calling `uses_data` on this should yield `["a", "b", "c"]` but instead only yields ["a", "b"].

Testing this on the online playground at https://jsonlogic.com/play.html with the data `{ "a": ["foo", "bar", "baz"], "b": "foo", "c": "bar" }` yields true. The actual JSONLogic is correct here but specifically `uses_data` is incorrect.

This PR attempts to fix this by always taking all values instead of the first.

arushs avatar Jun 08 '22 18:06 arushs