j-easy / easy-rules

The simple, stupid rules engine for Java
https://github.com/j-easy/easy-rules/wiki
MIT License
4.83k stars 1.04k forks source link

multiple rules in rule descriptor #416

Open Siktik opened 9 months ago

Siktik commented 9 months ago

hey,

i want to give a customer the possibility to write a .yml file that i read from for the programm. I was wondering if it is possible to have multiple rules in a rule descriptor .yml. In the examples there is always only one rule, if there is a way to read more rules i would really want to know how this could be achieved. Thank you in advance!

zhhaojie commented 9 months ago

Of course it can be supported, you can take a look at this implementation class.

https://github.com/j-easy/easy-rules/blob/master/easy-rules-support/src/main/java/org/jeasy/rules/support/reader/YamlRuleDefinitionReader.java

Finally, load them when your app started.

Siktik commented 9 months ago

aah, i was too quick there, found it when studying the yaml definitions. Thank you anyway sir this would have also helped, sure

CloudWangASP commented 22 hours ago

I try to fire this rules below, then failed, is there any issues in my Yml?


rules:


java.lang.IllegalArgumentException: The rule condition must be specified at org.jeasy.rules.support.reader.AbstractRuleDefinitionReader.createRuleDefinition(AbstractRuleDefinitionReader.java:81) at org.jeasy.rules.support.reader.AbstractRuleDefinitionReader.read(AbstractRuleDefinitionReader.java:45) at org.jeasy.rules.mvel.MVELRuleFactory.createRules(MVELRuleFactory.java:100)