Closed ailton-moreira closed 3 years ago
The rule engine is using MS Excel like formulas. To compare a string in Excel, only one = is used.
from business_rule_engine import RuleParser
def runHelloFunction():
print("this is from runHelloFunction")
return True
params = { 'text': 'Hello World'}
rules = """
rule "print hello world"
when
text = "Hello World"
then
runHelloFunction()
end
"""
parser = RuleParser()
parser.register_function(runHelloFunction)
parser.register_function(print)
parser.parsestr(rules)
parser.execute(params)
@manfred-kaiser thank you :) it works
I have param that is a string e.g params = { 'text': 'Hello World'}
My rules is: rules = """ rule "Say Hello" when text == 'Hello World' then runHelloFunction() end
""" But, when I try to run it gives me an error FormulaError: ('Not a valid formula:\n%s', "=text = 'Hello World'").
How can I compare strings there?