diff --git a/package.json b/package.json index a249aca..96f0510 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ballerine-nestjs-typebox", - "version": "3.0.2-next.8", + "version": "3.0.2-next.9", "description": "", "author": "Andrew Smiley ", "license": "MIT", @@ -27,6 +27,7 @@ "@nestjs/swagger": "^6.1.1 || ^7.0.11", "@sinclair/typebox": "^0.32.4", "ajv": "^8.14.0", + "ajv-formats": "^2.1.1", "rxjs": "^7.5.6" }, "dependencies": { @@ -37,7 +38,7 @@ "@nestjs/common": "^10.0.5", "@nestjs/core": "^10.0.5", "@nestjs/swagger": "^7.1.1", - "@sinclair/typebox": "^0.32.4", + "@sinclair/typebox": "0.32.15", "@types/node": "^20.4.1", "@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/parser": "^6.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b137295..2eca1ad 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ dependencies: ajv: specifier: ^8.14.0 version: 8.14.0 + ajv-formats: + specifier: ^2.1.1 + version: 2.1.1(ajv@8.14.0) fast-uri: specifier: ^2.3.0 version: 2.3.0 @@ -26,8 +29,8 @@ devDependencies: specifier: ^7.1.1 version: 7.3.1(@nestjs/common@10.3.8)(@nestjs/core@10.3.8)(reflect-metadata@0.2.2) '@sinclair/typebox': - specifier: ^0.32.4 - version: 0.32.31 + specifier: 0.32.15 + version: 0.32.15 '@types/node': specifier: ^20.4.1 version: 20.13.0 @@ -517,8 +520,8 @@ packages: engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} dev: true - /@sinclair/typebox@0.32.31: - resolution: {integrity: sha512-rYB0tgGHawpom3ZwwsGidvI0NI+W/rRHu1dyyO1KlIoH8iMdg3esSnYQxQtyJ8eflhqxmzEV7Nu8zT4JY7CHKw==} + /@sinclair/typebox@0.32.15: + resolution: {integrity: sha512-5Lrwo7VOiWEBJBhHmqNmf3TPB9ll8gcEshvYJyAIJyCZ2PF48MFOtiDHJNj8+FsNcqImaQYmxVkKBCBlyAa/wg==} dev: true /@types/json-schema@7.0.15: @@ -701,6 +704,17 @@ packages: hasBin: true dev: true + /ajv-formats@2.1.1(ajv@8.14.0): + resolution: {integrity: sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==} + peerDependencies: + ajv: ^8.0.0 + peerDependenciesMeta: + ajv: + optional: true + dependencies: + ajv: 8.14.0 + dev: false + /ajv@6.12.6: resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==} dependencies: diff --git a/src/decorators.ts b/src/decorators.ts index 43e6593..367f785 100644 --- a/src/decorators.ts +++ b/src/decorators.ts @@ -7,7 +7,6 @@ import { DECORATORS } from '@nestjs/swagger/dist/constants.js'; import { Static, TSchema, Type, TypeGuard } from '@sinclair/typebox'; import Ajv from 'ajv'; import fastUri from 'fast-uri'; - import { AjvValidationException } from './exceptions.js'; import { TypeboxTransformInterceptor } from './interceptors.js'; import type { @@ -23,6 +22,8 @@ import type { } from './types.js'; import { capitalize, coerceType, isObj } from './util.js'; +import AjvFormats from 'ajv-formats'; + const ajv = new Ajv({ coerceTypes: 'array', useDefaults: true, @@ -32,8 +33,13 @@ const ajv = new Ajv({ // Explicitly set allErrors to `false`. // When set to `true`, a DoS attack is possible. allErrors: false, + + // Our custom options: + keywords: ['transform'], }); +AjvFormats.default(ajv); + export function isSchemaValidator( // eslint-disable-next-line @typescript-eslint/no-explicit-any type: any