String based rule
Code Example:
BusinessRule rule = BusinessRuleBuilder.groovyRule("RULE_ID")
.withAlias("w", "WIDTH")
.withAlias("h", "HEIGHT")
.withGroovyCode("return w * h > 100")
.withErrorAliases("w", "h")
.withErrorMessage("Area must be less than or equal to 100")
.build();
This produces the following JSON output when rule is serialized:
{
"id": "RULE_ID",
"templateId": "groovyRule",
"errorMessage": "Area must be less than or equal to 100",
"namedAttributes": {
"w": "WIDTH",
"h": "HEIGHT"
},
"parameters": {
"customFunction": "return w \* h > 100",
"errorAttributes": [
"w",
"h"
]
},
"requiredContexts": \[],
"execution": "CONTINUOUS",
"businessRuleScopes": \[],
"staticProperties": {}
}
Updated over 1 year ago