validateWhereNode
validateWhereNode<
S>(props):VexWhereNode<S>
Defined in: packages/core/src/db/queryArgs.ts:229
Validates and normalises an untrusted where payload (a saved view row, a
URL query param, an MCP tool argument) into a VexWhereNode.
Runtime, not compile-time: a stored filter can go stale — a renamed
field, a dropped index, a schema change — in a way VexWhereNode<S>’s
compile-time field typing never catches for data that was not just typed
in an editor.
Type Parameters
Section titled “Type Parameters”S extends string = string
Collection slug to type the result against; the caller’s
responsibility to pick correctly, the same contract as JSON.parse<T>().
Parameters
Section titled “Parameters”Input props.
fields?
Section titled “fields?”readonly string[]
The collection’s known field names. Omitted
pre-vex generate or when the caller has no config handy — field names
then go unchecked, the same fallback ConstraintField uses, and
only shape and operators are validated.
unknown
The untrusted value, typically freshly JSON.parsed.
Returns
Section titled “Returns”VexWhereNode<S>
The same tree, narrowed to VexWhereNode.
Throws
Section titled “Throws”code: "INVALID_WHERE" — node is not an object; an
and / or whose value is not a non-empty array; a leaf missing field / op /
value; an op outside FilterOp (checked against
QUERY_FILTER_CONSTRAINT_COMPARATORS’s keys, the runtime source of truth); or, when
fields is given, a field not in it.