-
Notifications
You must be signed in to change notification settings - Fork 509
Is it possible to pass an array of objects as facts and then compare against a nested attribute #325
-
Hi,
I have an array of Objects, say [{ssn: '1234', netPay: '2000'}, {ssn: '4567', netPay: '4000'}]. Rules can be something like, ssn !=null and netPay>0. Is it possible to run this list against these set of rules? One way will be to use a loop in my javascript code and send this one at a time for the rule engine to evaluate the rules. But I was wondering whether this can do something like Drools, where I pass the whole list and then the Rule Engine takes care of the looping and validation.
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments 1 reply
-
@abhchowdhury was this resolved?
Beta Was this translation helpful? Give feedback.
All reactions
-
@abhchowdhury @abhchowdhury as I understand your request it isn't supported by default. Each call to engine.run is independent so it can be run on each element of the array.
Beta Was this translation helpful? Give feedback.
All reactions
-
You could write some custom operators (but not really that reusable) that would do certain assertions, given that the object structure remains the same. Something like everySSNIsGreaterThan, that would run a >= test inside every() for the given array. The (not so perfect) idea is to use every, and some to do your specific checks on that array in a single array. No idea if something like that will be sufficient for your use-cases, just throwing out there.
Beta Was this translation helpful? Give feedback.