Data Integrity
Notation prefers a loud failure over a silently wrong result. Two integrity checks guard filtering and glob normalization.
Glob List Integrity
Section titled “Glob List Integrity”A single glob list can’t mix object and array notations at the root — the root implies one source type, never both.
NotationGlob.normalize(['[*]', '!x.y']);// » throws NotationError — root is both array ([*]) and object (x.y)[*] says the source is an array, while !x.y says x is an object property
of the root — only one can be true.
Glob vs. Value Integrity
Section titled “Glob vs. Value Integrity”A negated glob with a trailing wildcard (!x.*) means empty x’s contents but
keep x. That only makes sense if x is actually a container. When the value’s
type contradicts the glob, filter() throws.
Notation.create({ x: { y: 1 } }).filter(['*', '!x.*']).value;// » { x: {} } ✓ x is an object, emptied as expectedBut if x isn’t an object:
Notation.create({ x: 1 }).filter(['*', '!x.*']).value;// » throws NotationError — can't empty a Number with "!x.*"The value 1 is a Number, so it can’t be reduced to {}. To remove it
outright, drop the trailing wildcard:
Notation.create({ x: 1 }).filter(['*', '!x']).value;// » {}Strict mode tightens this further: emptying a
null/undefined value with a trailing-wildcard negation also throws, rather
than being skipped.