Matcher operators
Every matcher/v1 operator, its operand, and when it passes, fails or cannot decide.
"Unknown" below means the result is unknown (undecidable) because the value has the wrong JSON type. Any operator
applied to a missing value fails, except exists, not, any_of and all_of, which decide for themselves.
A field pattern needs its parent to exist: { args: { options: { confirm: { exists: false } } } } fails when
options itself is missing, and is unknown when options is null, because the inner pattern only runs on an
object. To say "no confirm, wherever options is", write
{ any_of: [{ args: { options: { exists: false } } }, { args: { options: { confirm: { exists: false } } } }] }.
| Operator | Operand | Passes when | Unknown when |
|---|---|---|---|
equals | any JSON | deep equal (exact, not partial) | never |
fields | object of matchers | the value is an object and each listed field matches | not an object |
is | string number integer boolean object array null | the JSON type matches; integer is finite with no fraction | never |
exists | boolean | true: present (null counts as present). false: missing | never |
len | Range | code points of a string, items of an array or keys of an object are in range | not a string, array or object |
gt gte lt lte | number | the comparison holds | not a number (booleans are not numbers) |
contains | matcher | string: the operand is a substring. Array: some element matches | not a string or array, or a non-string operand on a string |
not_contains | matcher | the negation of contains | as contains |
icontains | string | substring under Unicode 16 simple case folding | not a string |
starts_with, ends_with | string | prefix or suffix | not a string |
regex | pattern, or { pattern, flags } with flags from i, m, s | RE2 search, unanchored | not a string |
glob | string | anchored: * any run, ? one code point, [a-z], [!a-z], \ escapes. A pattern with a / is a path glob (below) | not a string, a string with NUL, or a path that climbs above its root |
json_schema | JSON Schema 2020-12 (core's interpreter) | the value validates; a string is parsed as JSON first (unless compiled with parseJsonStrings: false) | a string that is not JSON |
jsonpath | { "<path>": matcher } | every selected node matches; nothing selected counts as missing | a string that is not JSON |
any_of | non-empty list | some matcher passes | none passes and some is unknown |
all_of | non-empty list | every matcher passes | none fails and some is unknown |
not | matcher | the matcher fails | the matcher is unknown |
judge | { rubric, threshold?, judge?, options? } | the judge passes it (score >= threshold when both exist) | never |
Path globs. When the pattern contains /, the value is treated as a path and normalized lexically before
matching, with no filesystem access and no symlink resolution: repeated / collapse, . segments drop, ..
removes the segment before it, and a trailing / drops (the pattern is normalized the same way). So
{ glob: "/tmp/**" } fails on /tmp/../etc/passwd, which is /etc/passwd, and { glob: "/etc/**" } passes on
it. In a path glob *, ? and negated classes stay inside one segment, ** crosses segments, and a segment that is
only ** also matches no segment: /home/*/public/** does not match /home/a/private/x/public/y, and /a/**/b
matches /a/b. /etc/** does not match /etc itself.
The glob fails closed: the result is unknown (a deny rule treats it as a match; an allow rule, an eval and not
do not) when a .. would climb above the root (/../etc) or above the start of a relative path (a/../..), when
an absolute pattern meets a value that is not absolute (etc/passwd, ~/.ssh/id_rsa, the empty string), and for
any glob value containing NUL. Pass policies absolute, resolved paths. Only / separates segments: a backslash,
%2e%2e or any other encoding is literal text. Matching is case-sensitive, so on a case-insensitive filesystem
/Users/*/.ssh/** does not match /Users/a/.SSH/id_rsa; normalize case before matching there. A path glob with a
.. segment is a load error. A pattern without / matches the raw string, and its * crosses /.
JSONPath is a subset of RFC 9535: $, .name, ['name'], [n], [-n], [*], .*. Filters, slices, unions
and .. are load errors. Regex is RE2 in both languages: linear time, no lookaround, no backreferences, \d and
\w are ASCII. String operators never stringify: the number 42 does not contain "4".
Load-time checks: unknown or mixed operator keys (with did-you-mean), keys one edit away from an operator, the
pre-v1 names type, path, length and schema when their value looks like that operator, operand types,
invalid regex, glob, JSONPath and JSON Schema, integers beyond +/-(2^53 - 1), empty any_of / all_of, Range
min <= max, judge.threshold in [0, 1], and the operator allowlist.