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
*[engine.addOperator(String operatorName, Function evaluateFunc(factValue, jsonValue))](#engineaddoperatorstring-operatorname-function-evaluatefuncfactvalue-jsonvalue)
@@ -43,6 +45,11 @@ let engine = new Engine([Array rules], options)
43
45
an exception is thrown. Turning this option on will cause the engine to treat
44
46
undefined facts as `undefined`. (default: false)
45
47
48
+
`allowUndefinedConditions` - By default, when a running engine encounters a
49
+
condition reference that cannot be resolved an exception is thrown. Turning
50
+
this option on will cause the engine to treat unresolvable condition references
51
+
as failed conditions. (default: false)
52
+
46
53
`pathResolver` - Allows a custom object path resolution library to be used. (default: `json-path` syntax). See [custom path resolver](./rules.md#condition-helpers-custom-path-resolver) docs.
47
54
48
55
### engine.addFact(String id, Function [definitionFunc], Object [options])
Adds or updates a condition to the engine. Rules may include references to this condition. Conditions must start with `all`, `any`, `not`, or reference a condition.
@@ -136,7 +137,7 @@ See the [hello-world](../examples/01-hello-world.js) example.
136
137
137
138
### Boolean expressions: `all`, `any`, and `not`
138
139
139
-
Each rule's conditions *must* have an `all` or `any` operator containing an array of conditions at its root or a `not` operator containing a single condition. The `all` operator specifies that all conditions contained within must be truthy for the rule to be considered a `success`. The `any` operator only requires one condition to be truthy for the rule to succeed. The `not` operator will negate whatever condition it contains.
140
+
Each rule's conditions *must* have an `all` or `any` operator containing an array of conditions at its root, a `not` operator containing a single condition, or a condition reference. The `all` operator specifies that all conditions contained within must be truthy for the rule to be considered a `success`. The `any` operator only requires one condition to be truthy for the rule to succeed. The `not` operator will negate whatever condition it contains.
140
141
141
142
```js
142
143
// all:
@@ -174,7 +175,30 @@ let rule = new Rule({
174
175
})
175
176
```
176
177
177
-
Notice in the second example how `all`, `any`, and 'not' can be nested within one another to produce complex boolean expressions. See the [nested-boolean-logic](../examples/02-nested-boolean-logic.js) example.
178
+
Notice in the second example how `all`, `any`, and `not` can be nested within one another to produce complex boolean expressions. See the [nested-boolean-logic](../examples/02-nested-boolean-logic.js) example.
179
+
180
+
### Condition Reference
181
+
182
+
Rules may reference conditions based on their name.
183
+
184
+
```js
185
+
let rule =newRule({
186
+
conditions: {
187
+
all: [
188
+
{ condition:'conditionName' },
189
+
{ /* additional condition */ }
190
+
]
191
+
}
192
+
})
193
+
```
194
+
195
+
Before running the rule the condition should be added to the engine.
0 commit comments