UNPKG

nestjs-typebox

Version:

This library provides helper utilities for writing and validating NestJS APIs using [TypeBox](https://github.com/sinclairzx81/typebox) as an alternative to class-validator/class-transformer. Can be configured to patch @nestjs/swagger allowing OpenAPI gene

7 lines (6 loc) 1.1 kB
import { StaticDecode, type TSchema } from '@sinclair/typebox'; import type { HttpEndpointDecoratorConfig, MethodDecorator, RequestConfigsToTypes, RequestValidatorConfig, SchemaValidator, SchemaValidatorConfig, ValidatorConfig } from './types.js'; export declare function isSchemaValidator(type: any): type is SchemaValidator; export declare function buildSchemaValidator(config: SchemaValidatorConfig): SchemaValidator; export declare function Validate<T extends TSchema, RequestValidators extends RequestValidatorConfig[], MethodDecoratorType extends (...args: [...RequestConfigsToTypes<RequestValidators>, ...any[]]) => Promise<StaticDecode<T>> | StaticDecode<T>>(validatorConfig: ValidatorConfig<T, RequestValidators>): MethodDecorator<MethodDecoratorType>; export declare const HttpEndpoint: <S extends TSchema, RequestConfigs extends RequestValidatorConfig[], MethodDecoratorType extends (...args: [...RequestConfigsToTypes<RequestConfigs>, ...any[]]) => Promise<StaticDecode<S>> | StaticDecode<S>>(config: HttpEndpointDecoratorConfig<S, RequestConfigs>) => MethodDecorator<MethodDecoratorType>;