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
Copy file name to clipboardExpand all lines: docs/rules.md
+14-5
Original file line number
Diff line number
Diff line change
@@ -134,9 +134,9 @@ let rule = new Rule({
134
134
135
135
See the [hello-world](../examples/01-hello-world.js) example.
136
136
137
-
### Boolean expressions: `all`and `any`
137
+
### Boolean expressions: `all`, `any`, and `not`
138
138
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.
140
140
141
141
```js
142
142
// all:
@@ -158,14 +158,23 @@ let rule = new Rule({
158
158
{ /* condition 2 */ },
159
159
{ /* condition n */ },
160
160
{
161
-
all: [ /* more conditions */ ]
161
+
not: {
162
+
all: [ /* more conditions */ ]
163
+
}
162
164
}
163
165
]
164
166
}
165
167
})
168
+
169
+
// not:
170
+
let rule =newRule({
171
+
conditions: {
172
+
not: { /* condition */ }
173
+
}
174
+
})
166
175
```
167
176
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.
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.
322
331
323
332
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.
0 commit comments