You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, in the actual code, it doesn't look like working as it described in the example. "==" seems to limit that only when one kind of condition is in the condition list, it will work. For mixed situation it doesn't seem work.
Current Code in business_rules/engine.py :
defcheck_conditions_recursively(conditions, defined_variables):
keys=list(conditions.keys())
ifkeys== ['all']:
assertlen(conditions['all']) >=1forconditioninconditions['all']:
ifnotcheck_conditions_recursively(condition, defined_variables):
returnFalsereturnTrueelifkeys== ['any']:
assertlen(conditions['any']) >=1forconditioninconditions['any']:
ifcheck_conditions_recursively(condition, defined_variables):
returnTruereturnFalseelse:
# help prevent errors - any and all can only be in the condition dict# if they're the only itemassertnot ('any'inkeysor'all'inkeys)
returncheck_condition(conditions, defined_variables)
Here, me and my team want to have a mixed rule with both ANY and ALL conditions, and also wish it won't make any final decision when just validating one of it. So first to check if ANY or ALL exists, then start checking one of it, if doesn't apply, then go to validate the other one if exists.
Proposal code (mainly update "keys == ..." to "... in keys" and update the return condition):
defcheck_conditions_recursively(conditions, defined_variables):
keys=list(conditions.keys())
if'any'inkeys:
assertlen(conditions['any']) >=1forconditioninconditions['any']:
ifcheck_conditions_recursively(condition, defined_variables):
returnTrueif'all'notinkeys:
returnFalseelif'all'inkeys:
assertlen(conditions['all']) >=1forconditioninconditions['all']:
ifnotcheck_conditions_recursively(condition, defined_variables):
returnFalsereturnTrueelse:
# help prevent errors - any and all can only be in the condition dict# if they're the only itemassertnot ('any'inkeysor'all'inkeys)
returncheck_condition(conditions, defined_variables)
Please feel free to leave any comments to help me have a better understanding of this part of code. Thank you!
The text was updated successfully, but these errors were encountered:
Based on the rules example in ReadMe, we are able to have both ANY and ALL conditions in one rule and pass it to Venmo/business-rules.
However, in the actual code, it doesn't look like working as it described in the example. "==" seems to limit that only when one kind of condition is in the condition list, it will work. For mixed situation it doesn't seem work.
Current Code in
business_rules/engine.py
:Here, me and my team want to have a mixed rule with both ANY and ALL conditions, and also wish it won't make any final decision when just validating one of it. So first to check if ANY or ALL exists, then start checking one of it, if doesn't apply, then go to validate the other one if exists.
Proposal code (mainly update "keys == ..." to "... in keys" and update the return condition):
Please feel free to leave any comments to help me have a better understanding of this part of code. Thank you!
The text was updated successfully, but these errors were encountered: