-
Notifications
You must be signed in to change notification settings - Fork 11
Description
@TotalTechGeek awesome job with the traversal stuff! We made the switch to this library for that functionality.
if/and/or works as expected if it returns a string, number, or boolean. However, if the if conditional returns an object, it returns undefined because https://github.com/TotalTechGeek/json-logic-engine/blob/master/defaultMethods.js#L53 returns this as a context for another rule. It seems to me that the expected behavior would be that if the context is not a rule, it should just return the object.
TLDR; If I use JSON logic conditional that returns an object that is not a rule then I get the object back, if I use JSON Logic Engine I do not.
This might all be fixed if _parse would just return data if not satisfied.
Quick way to reproduce the issue is:
const data = {
first_name: true
}
const rule = {
if: [
{
"===": [
{
var: "first_name"
},
true
]
},
{ first_name: "scott" },
{ first_name: "no idea" }
]
}
const result = logic.run(rule, data)
console.log(result) // 'undefined'