@inixiative/json-rules 3.9.0 → 3.11.0

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 CHANGED
@@ -628,6 +628,21 @@ declares: on Json, `contains` / `startsWith` / `endsWith` become `string_contain
628
628
  becomes one `equals` per value; on a scalar list, `contains` becomes `has` and emptiness
629
629
  `isEmpty`; `caseInsensitive` adds `mode: 'insensitive'` on text only.
630
630
 
631
+ ### A value the row doesn't carry
632
+
633
+ By default `check()` reads an absent path as null, as a column is on the compiled rails.
634
+ `check(rule, row, { absent: 'unknown' })` reads it as unknown instead: `null === null`, and
635
+ `undefined` is not null. Every operator fails on an unknown field or compared `path`, `equals
636
+ null` and `in [null]` included, except the ones that hold on a missing value (`isEmpty`,
637
+ `notExists` and the negations), which keep their meaning. Use it when the row is a partial stand-in
638
+ for real rows (a pseudo record a grant is checked against), so a rule passes only on what the row
639
+ pins. `check()` only; the compilers read real columns.
640
+
641
+ `validateRule(rule, { positive: true })` refuses every shape that can hold on a missing value —
642
+ `if`/`then`/`else`, array and aggregate rules, the negations, `isEmpty` and `notExists` — so a rule
643
+ checked that way passes only on what the row carries. A rule that means "no value" says `equals
644
+ null`.
645
+
631
646
  ## Engine Globals
632
647
 
633
648
  `engineGlobals` holds process-wide defaults. Keys are dotted paths into one state object.