json-rules-engine icon indicating copy to clipboard operation
json-rules-engine copied to clipboard

Add "not" boolean operator

Open andycoopcode opened this issue 3 years ago • 7 comments

I've had difficulty expressing certain rules in a readable way without the ability to negate conditions.

For instance if I wanted to create a rule saying "trigger an event when there is not any condition which is true," I would instead have to express this as "trigger an event when all conditions are false." This means that I would have to write each condition as its logical negation, which potentially affects the readability of the condition.

These changes add in a new not boolean operator alongside all and any which negates the result of whatever single condition is nested inside it.

I believe this addresses issue https://github.com/CacheControl/json-rules-engine/issues/269.

andycoopcode avatar Jul 21 '21 17:07 andycoopcode

It's look nice! Very helpfull

liquid36 avatar Aug 12 '21 12:08 liquid36

Hi, is there anything stopping this PR from being merged? I was just about to create an issue on this too and would find it very useful. 👍

cgerikj avatar Sep 13 '21 13:09 cgerikj

This would be a great addition!

frebos88 avatar Sep 21 '21 12:09 frebos88

Would love this feature!

mnording avatar Sep 21 '21 13:09 mnording

+1

RobbeCl avatar Sep 26 '21 18:09 RobbeCl

We could really use this feature!!! +1

gnowakpoloniex avatar Oct 01 '21 14:10 gnowakpoloniex

"trigger an event when there is not any condition which is true," I would instead have to express this as "trigger an event when all conditions are false."

I've read that three times now and the second one is significantly more understandable to me. More succinct, less complex, less mental effort required (all conditions must be false, rather than "not any condition which is true"). The first one may seem more readable and understandable to you currently, but thats not as important as it being readable by others (and you) later.

StingyJack avatar Feb 28 '22 05:02 StingyJack

Hi, I'm the original creator of this PR, just under a different account! 😄

@StingyJack I agree with you that the given example frames the need for a NOT operator poorly by doing so in the context of an any vs. all scenario. The intended value here is primarily in the following statement:

This means that I would have to write each condition as its logical negation, which potentially affects the readability of the condition.

Broadly speaking, being forced to manually negate a condition (without a NOT operator) which is more clearly expressed in either its positive/negative form, especially if it's deeply nested, can get messy.

andrewjleung avatar Nov 15 '22 15:11 andrewjleung

@andrewjleung nice seeing you 😆 if this PR merges by next year, I'll buy you a beer!

gnowakpoloniex avatar Nov 15 '22 15:11 gnowakpoloniex

any update on this feature PR please ?

nileio avatar Feb 26 '23 03:02 nileio

@andrewjleung I'm working with @CacheControl to help maintain this project now. I've been a bit out of pocket today but I hope to get a chance to review, test, and merge this PR before the weekend.

Thanks for putting this together, and sorry about the wait.

chris-pardy avatar Jun 29 '23 20:06 chris-pardy