class ValidationService
implements IValidationService
Since 0.1.0

Default validation service.

The error formatter is resolved once at plugin construction time and passed in here, avoiding per-request formatter resolution.

Constructors

ValidationService(
schemaPolicy?: SchemaPolicy
)

Methods

middleware(
schema: unknown,
target: ValidationTarget
): MiddlewareFunction

Creates validation middleware for the given request target.

Uses the formatter resolved at plugin construction time.

validate<T>(
schema: unknown,
data: unknown
): Result<T, readonly ValidationIssue[]>

Validate data against the given schema.

The schema is expected to expose a safeParse method (Zod-compatible). On success the parsed value is returned wrapped in ok(); on failure the validator issues are mapped to ValidationIssue elements and returned via err().

Usage

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