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
@@ -129,7 +140,7 @@ There are 4 types of operators you can use (evaluated in that order of precedenc
129
140
-`and` - accepts a non-empty list of expressions
130
141
-`or` - accepts a non-empty list of expressions
131
142
-`not` - accepts another expressions
132
-
-`<user defined funcs>` - accepts any type of argument and evaluated by the user defined functions and the given context. Can be async.
143
+
-`<user defined funcs>` - accepts any type of argument and evaluated by the user defined functions, and the given context (can be async).
133
144
-`<compare funcs>` - operates on one of the context properties and compares it to a given value.
134
145
-`{property: {op: value}}`
135
146
- available ops:
@@ -145,13 +156,36 @@ There are 4 types of operators you can use (evaluated in that order of precedenc
145
156
- `inq: any[]` - True if in an array of values. Comparison is done using the `===` operator
146
157
- `between: readonly [number, number] (as const)` - True if the value is between the two specified values: greater than or equal to first value and less than or equal to second value.
147
158
-`{property: value}`
148
-
- compares the property to that value (shorthand to the `eq` op)
159
+
- compares the property to that value (shorthand to the `eq` op, without the option to user math or refs to other properties)
149
160
150
161
> Nested properties in the context can also be accessed using a dot notation (see example above)
162
+
151
163
> In each expression level, you can only define 1 operator, and 1 only
152
164
153
-
> You can reference values (and nested values) from the context using the {"ref":"<dotnotationpath>"}
154
-
> (see example above) on the right-hand side of expressions (not in parameters to user defined functions though)
165
+
The right-hand side of compare (not user defined) functions can be a:
166
+
- literal - number/string/boolean (depending on the left-hand side of the function)
167
+
- reference to a property (or nested property) in the context.
168
+
This can be achieved by using `{"ref":"<dot notation path>"}`
169
+
- A math operation that can reference properties in the context.
170
+
The valid operations are `+,-,*,/,%,pow`.
171
+
This can be achieved by using
172
+
```json
173
+
{
174
+
"op": "<+,-,*,/,%,pow>",
175
+
"lhs": {"ref": "<dot notation path>"}, // or a number literal
176
+
"rhs": {"ref": "<dot notation path>"} // or a number literal
177
+
}
178
+
```
179
+
which will be computed as `<lhs> <op> <rhs>` where lhs is left-hand-side and rhs is right-hand-side. So for example
180
+
```json
181
+
{
182
+
"op": "/",
183
+
"lhs": 10,
184
+
"rhs": 2
185
+
}
186
+
```
187
+
will equal `10 / 2 = 5`
188
+
155
189
156
190
Example expressions, assuming we have the `user` and `maxCount` user defined functions in place can be:
0 commit comments