Commit cd78db5 1 parent b48735a commit cd78db5 Copy full SHA for cd78db5
File tree 1 file changed +32
-1
lines changed
1 file changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ npm install --s json-rules-engine-simplified
31
31
The simplest example of using ` json-rules-engine-simplified `
32
32
33
33
``` jsx
34
- import { Engine } from ' json-rules-engine-simplified'
34
+ import Engine from ' json-rules-engine-simplified'
35
35
36
36
let rules = [{
37
37
conditions: {
@@ -65,6 +65,37 @@ engine
65
65
66
66
Rules engine expects to know all the rules in advance, it effectively drops builder pattern, but keeps the interface.
67
67
68
+ ### Appending rule to existing engine
69
+
70
+ You don't have to specify all rules at the construction time, you can add rules in different time in process.
71
+ In order to add new rules to the ` Engine ` use ` addRule ` function.
72
+
73
+ For example, following declarations are the same
74
+ ``` js
75
+ import Engine from ' json-rules-engine-simplified' ;
76
+
77
+ let engineA = new Engine ();
78
+
79
+ let rule = {
80
+ conditions: {
81
+ firstName: " empty"
82
+ },
83
+ event : {
84
+ type: " remove" ,
85
+ params: {
86
+ field: " password"
87
+ },
88
+ }
89
+ };
90
+
91
+ engineA .addRule (rule);
92
+
93
+ let engineB = new Engine (rule);
94
+
95
+ ```
96
+
97
+ In this case ` engineA ` and ` engineB ` will give the same results.
98
+
68
99
## Validation
69
100
70
101
In order to prevent most common errors, ` Engine ` does initial validation on the schema, during construction.
You can’t perform that action at this time.
0 commit comments