Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Is it possible to pass an array of objects as facts and then compare against a nested attribute #325

abhchowdhury started this conversation in General
Discussion options

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.

You must be logged in to vote

Replies: 2 comments 1 reply

Comment options

@abhchowdhury was this resolved?

You must be logged in to vote
1 reply
Comment options

@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.

Comment options

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.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

AltStyle によって変換されたページ (->オリジナル) /