Skip to content

Commit 0132eb2

Browse files
committed
Update rules documentation with new condition
1 parent 721410d commit 0132eb2

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

docs/rules.md

+14-5
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ let rule = new Rule({
134134

135135
See the [hello-world](../examples/01-hello-world.js) example.
136136

137-
### Boolean expressions: `all` and `any`
137+
### Boolean expressions: `all`, `any`, and `not`
138138

139-
Each rule's conditions *must* have either an `all` or an `any` operator at its root, containing an array of conditions. 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.
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.
140140

141141
```js
142142
// all:
@@ -158,14 +158,23 @@ let rule = new Rule({
158158
{ /* condition 2 */ },
159159
{ /* condition n */ },
160160
{
161-
all: [ /* more conditions */ ]
161+
not: {
162+
all: [ /* more conditions */ ]
163+
}
162164
}
163165
]
164166
}
165167
})
168+
169+
// not:
170+
let rule = new Rule({
171+
conditions: {
172+
not: { /* condition */ }
173+
}
174+
})
166175
```
167176

168-
Notice in the second example how `all` and `any` can be nested within one another to produce complex boolean expressions. See the [nested-boolean-logic](../examples/02-nested-boolean-logic.js) example.
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.
169178

170179
### Condition helpers: `params`
171180

@@ -318,7 +327,7 @@ engine.on('failure', function(event, almanac, ruleResult) {
318327
319328
## Operators
320329
321-
Each rule condition must begin with a boolean operator(```all``` or ```any```) at its root.
330+
Each rule condition must begin with a boolean operator(```all```, ```any```, or ```not```) at its root.
322331
323332
The ```operator``` compares the value returned by the ```fact``` to what is stored in the ```value``` property. If the result is truthy, the condition passes.
324333

0 commit comments

Comments
 (0)