jruizgit / rules

Durable Rules Engine
MIT License
1.16k stars 206 forks source link

Other issues found with nested arrays #248

Open hea-lab opened 5 years ago

hea-lab commented 5 years ago

This issue is similar to #189

The following two examples should not trigger the action, but they do with the current code

d.ruleset('test', function() {
        whenAll: m.array1.anyItem(item.array2.anyItem(item.field21 == 2) && item.field == 8 && +item.field2)
});

d.post('test',{array1: [{array2 : [{field21 : 2}], field : 8}]});
d.ruleset('test', function() {
        whenAll: m.array1.anyItem(item.array2.anyItem(item.field21 == 2) || item.field == 8)
        run: console.log("ok", JSON.stringify(m))
});

d.post('test',{array1: [{array2 : [{field21 : 3}], field : 3}]});
jruizgit commented 5 years ago

Hi, I'm working on a fix. Unfortunately it is a little more involved.

jruizgit commented 5 years ago

I have pushed a fix for array evaluation. The rules above now work as expected. Please use version 2.0.7.