@inixiative/json-rules 2.19.1 → 2.19.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -5
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -8
- package/dist/index.d.ts +4 -8
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -336,6 +336,18 @@ Inside array conditions, `$.` means "read from the current element":
|
|
|
336
336
|
}
|
|
337
337
|
```
|
|
338
338
|
|
|
339
|
+
## Rule Introspection
|
|
340
|
+
|
|
341
|
+
Reading a stored rule's own content — which values it names, which bindings it needs — is
|
|
342
|
+
engine work, not caller work: a walk written outside the engine goes blind the day the rule
|
|
343
|
+
format grows a node type, and it goes blind silently.
|
|
344
|
+
|
|
345
|
+
| Function | Purpose |
|
|
346
|
+
| --- | --- |
|
|
347
|
+
| `requiredBindings(rule)` | Names of every `{ bind }` token in the tree — the set a bindings map must cover. |
|
|
348
|
+
| `resolveBindings(rule, bindings)` | Substitutes covered binds with their values, leaving uncovered tokens in place (partial resolution). |
|
|
349
|
+
|
|
350
|
+
|
|
339
351
|
## Runtime Validation
|
|
340
352
|
|
|
341
353
|
`check()` evaluates a rule against data and returns:
|
|
@@ -516,15 +528,20 @@ comes from the field map: `FieldMapEntry.isRequired: false` (prisma-map emits it
|
|
|
516
528
|
Without `{ map, model }`, or on an entry that doesn't declare it, the bare
|
|
517
529
|
`not` / `notIn` is emitted and NULL rows fall out, as they always did.
|
|
518
530
|
|
|
519
|
-
Date rules
|
|
520
|
-
boundary is not something a NULL column satisfies, so `check()`
|
|
521
|
-
ordinary non-match (honoring `error`)
|
|
522
|
-
|
|
531
|
+
Date rules follow the same split. The positive operators answer non-match on both
|
|
532
|
+
rails — a bare boundary is not something a NULL column satisfies, so `check()`
|
|
533
|
+
reports the rule's ordinary non-match (honoring `error`) and the compilers keep the
|
|
534
|
+
bare `<` / `BETWEEN`. The negative-flavored ones (`notBetween`, `dayNotIn`) follow
|
|
535
|
+
the negation ruling instead: a never-set date is not in the range, so a null column
|
|
536
|
+
MATCHES, and the compilers carry the `IS NULL` arm. To match never-seen rows under a
|
|
537
|
+
positive operator, ask for them:
|
|
523
538
|
`{ any: [{ field, operator: 'notExists' }, { field, dateOperator: 'before', … }] }`.
|
|
524
539
|
|
|
525
540
|
| Rule | `check()` on `{ col: null }` | `toSql()` | `toPrisma()` |
|
|
526
541
|
| --- | --- | --- | --- |
|
|
527
|
-
|
|
|
542
|
+
| positive `dateOperator` (`before`, `between`, `dayIn`, …) | no match | `col < $1` (NULL never satisfies) | `{ col: { lt: … } }` |
|
|
543
|
+
| `notBetween` | matches | `(col NOT BETWEEN $1 AND $2 OR col IS NULL)` | `{ OR: [{ col: { NOT: … } }, { col: { equals: null } }] }` (nullable column, same field-map licensing as above) |
|
|
544
|
+
| `dayNotIn` | matches | `(EXTRACT(DOW FROM col) <> ALL($1) OR col IS NULL)` | — (no Prisma output) |
|
|
528
545
|
| `notExists` OR `before` | matches via the first arm | `(col IS NULL OR col < $1)` | `{ OR: [{ col: { equals: null } }, { col: { lt: … } }] }` |
|
|
529
546
|
|
|
530
547
|
`0` is an instant (1970-01-01) and compares; `''` is malformed data and raises
|