nadirizr / json-logic-py

Build complex rules, serialize them as JSON, and execute them in Python
MIT License
178 stars 87 forks source link

Include in comparation to work with list #12

Open ainokila opened 5 years ago

ainokila commented 5 years ago

It would be a good improvement, to contemplate the in operation to work with lists and tuples.

Example:

rule = {"in" : [ { "var" : "temp" }, 110 ]}

data = { "temp" : [99, 100, 101]}

jsonLogic(rules, data)
# True

https://github.com/nadirizr/json-logic-py/pull/13

Vladkryvoruchko commented 4 years ago

@ainokila I think this a bit off the way "in" is designed to work. Think about this as: "n in m", where m must be always an iterable and n is user data

what you suggest is: "n contains m"?

Im also not sure how [99, 100, 101] in 110 might produce True as output ?