assertMongoFieldPath
function assertMongoFieldPath(field): string;Defined in: pagination-mongo.ts:48
Validate a Mongo field path used by the keyset adapter.
Accepts dotted paths such as author.name; rejects $ operators,
whitespace, empty segments, and other unsafe field strings. Field mappings
must be server-owned and should never come from request data.
toMongoKeyset runs every mapped field through it; call it yourself
when building other filters from configurable field names.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
field |
string |
Returns
Section titled “Returns”string
The same field, unchanged, when valid.
Throws
Section titled “Throws”If field is not a dot-separated list of identifiers.
Example
Section titled “Example”import { assertMongoFieldPath } from "@xtandard/lib/pagination/mongo";
assertMongoFieldPath("author.name"); // "author.name"assertMongoFieldPath("$where"); // throws: invalid field path "$where"assertMongoFieldPath("a..b"); // throws: invalid field path "a..b"