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
18 lines (13 loc) • 515 B
text/typescript
import { DefaultErrorFunction, SetErrorFunction } from '@sinclair/typebox/errors';
import { setFormats } from './formats.js';
import { patchNestJsSwagger } from './swagger-patch.js';
import { Configure } from './types.js';
export const configureNestJsTypebox = (options?: Configure) => {
SetErrorFunction(params => params.schema.errorMessage ?? DefaultErrorFunction(params));
if (options?.patchSwagger) {
patchNestJsSwagger();
}
if (options?.setFormats) {
setFormats();
}
};