Not on entire condition similar to all and any
See original GitHub issueNot operator on entire condition. An operator similar to how all or any works but unary and returns true when the condition is evaluated to false. Example below:
not: { any:[{ fact: 'employee', operator: 'equal', path: '.company', value: 'Microsoft', }, { fact: 'employee', operator: 'equal', path: '.company', value: 'Amazon', } ] }
Agreed that there are other ways to write the rule to support this, but that limits re-use of conditions and reduces using them without writing code for it, Ways are as follows:
- apply demorgan’s law to get to negate the whole condition.
- add them as dynamic facts and reuse them accordingly.
In my use case, i have a large number of conditions, which are dynamically added to other sets of rules using const objects. The lack of the not cripples this use case. If there is another way of achieving this without adding dynamic facts through code, please let me know.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
Top GitHub Comments
Since you seem to be waiting for many people to ask for this feature before deciding to write it, I just want to add that I came here looking for the exact same functionality, so it is something that would be very helpful 👍
(I understand your reasoning for not having it at this point, btw. And thanks for an excellent and very useful lib!)