I've noticed that the in operator is failing when receiving nil values as the array.
Context:
We have been using JSONLogic for a couple of years now to evaluate rules on serialized objects at runtime. Most of the time, we don't know the actual values of the variables used in the rules since they are built by serializing objects retrieved from our database.
Current behavior:
When the variable (array to search in) doesn't exist in the object, a nil value is passed as the array, so in that case the gem is failing due to a NoMethodError: undefined methodinclude?' for nil:NilClass`.
Here you can see an example:
rule = {"in" => ["value_to_search", {"var" => "array"}]}
variable = {"array" => nil} (Consider that nil is the value after some processing at runtime)
JSONLogic.apply(rule, variable)
I've noticed that the
in
operator is failing when receivingnil
values as the array.Context:
We have been using JSONLogic for a couple of years now to evaluate rules on serialized objects at runtime. Most of the time, we don't know the actual values of the variables used in the rules since they are built by serializing objects retrieved from our database.
Current behavior:
When the variable (array to search in) doesn't exist in the object, a
nil
value is passed as the array, so in that case the gem is failing due to aNoMethodError: undefined method
include?' for nil:NilClass`.Here you can see an example:
The output: