interface ValidationPluginOptions
Since 0.1.0

Options for ValidationPlugin.

Properties

Error response format. Defaults to 'default'.

Pass 'default', 'rfc9457', or 'nestjs' for built-in formatters, or provide a custom ValidationErrorFormatter function.

readonly
optional
whitelist: boolean

When true, strip properties the schema does not declare.

Applied once per middleware at registration time by calling the schema's own .strip() (Zod-style). A schema that does not expose .strip() — a non-object schema, or a validator other than Zod — is used unchanged, since schemas are duck-typed through safeParse.

readonly
optional
forbidNonWhitelisted: boolean

When true, reject payloads carrying properties the schema does not declare.

Applied once per middleware at registration time by calling the schema's own .strict() (Zod-style), and takes precedence over ValidationPluginOptions.whitelist when both are set (rejecting is stronger than stripping). A schema that does not expose .strict() is used unchanged.

Usage

import { type ValidationPluginOptions } from "validation-plugin/src/index.ts";