Skip to content

assertPrismaField

function assertPrismaField(field): string;

Defined in: pagination-prisma.ts:47

Validate a Prisma scalar field name used by the keyset adapter: a single identifier ([a-zA-Z_][a-zA-Z0-9_]*), no dots or relation paths. toPrismaKeyset runs every mapped field through it. Field mappings must be server-owned and should never come from request data.

Parameter Type
field string

string

The same field, unchanged, when valid.

If field is not a plain identifier.

import { assertPrismaField } from "@xtandard/lib/pagination/prisma";
assertPrismaField("createdAt"); // "createdAt"
assertPrismaField("author.name"); // throws: invalid field "author.name"