UNPKG

jsonv-ts

Version:

JSON Schema builder and validator for TypeScript with static type inference, Hono middleware for OpenAPI generation and validation, and MCP server/client implementation. Lightweight, dependency-free, and built on Web Standards.

24 lines (23 loc) 859 B
import type { Schema } from "../schema"; import type { Static } from "../static"; import type { StaticCoerced } from "../static"; import type { ErrorDetail } from "../utils/details"; export declare class InvalidSchemaError extends Error { schema: Schema; value: unknown; errors: ErrorDetail[]; constructor(schema: Schema, value: unknown, errors?: ErrorDetail[]); first(): ErrorDetail; firstToString(): string; } export type ParseOptions = { withDefaults?: boolean; withExtendedDefaults?: boolean; coerce?: boolean; coerceDropUnknown?: boolean; clone?: boolean; onError?: (errors: ErrorDetail[]) => void; }; export declare function parse<S extends Schema, Options extends ParseOptions = ParseOptions>(_schema: S, v: unknown, opts?: Options): Options extends { coerce: true; } ? StaticCoerced<S> : Static<S>;