From c5dcc8a3d38db139d92cb0722e20beda84d6220e Mon Sep 17 00:00:00 2001 From: Phil Date: Wed, 2 Aug 2023 09:15:02 +0200 Subject: [PATCH 1/2] feat(typebox): allow TUnion inside getValidator --- packages/typebox/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/typebox/src/index.ts b/packages/typebox/src/index.ts index 0362793145..9efe1b869f 100644 --- a/packages/typebox/src/index.ts +++ b/packages/typebox/src/index.ts @@ -1,4 +1,4 @@ -import { Type, TObject, TInteger, TOptional, TSchema, ObjectOptions, TIntersect } from '@sinclair/typebox' +import { Type, TObject, TInteger, TOptional, TSchema, ObjectOptions, TIntersect, TUnion } from '@sinclair/typebox' import { jsonSchema, Validator, DataValidatorMap, Ajv } from '@feathersjs/schema' export * from '@sinclair/typebox' @@ -17,7 +17,7 @@ export type TDataSchemaMap = { * @param validator The AJV validation instance * @returns A compiled validation function */ -export const getValidator = (schema: TObject | TIntersect, validator: Ajv): Validator => +export const getValidator = (schema: TObject | TIntersect | TUnion, validator: Ajv): Validator => jsonSchema.getValidator(schema as any, validator) /** From e7ce131cf1334ca91a177ff040bb0d6bed69cf16 Mon Sep 17 00:00:00 2001 From: daffl Date: Wed, 16 Aug 2023 10:04:41 -0700 Subject: [PATCH 2/2] Formatting --- packages/typebox/src/index.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/typebox/src/index.ts b/packages/typebox/src/index.ts index 9efe1b869f..2f338703c4 100644 --- a/packages/typebox/src/index.ts +++ b/packages/typebox/src/index.ts @@ -1,4 +1,13 @@ -import { Type, TObject, TInteger, TOptional, TSchema, ObjectOptions, TIntersect, TUnion } from '@sinclair/typebox' +import { + Type, + TObject, + TInteger, + TOptional, + TSchema, + ObjectOptions, + TIntersect, + TUnion +} from '@sinclair/typebox' import { jsonSchema, Validator, DataValidatorMap, Ajv } from '@feathersjs/schema' export * from '@sinclair/typebox' @@ -17,8 +26,10 @@ export type TDataSchemaMap = { * @param validator The AJV validation instance * @returns A compiled validation function */ -export const getValidator = (schema: TObject | TIntersect | TUnion, validator: Ajv): Validator => - jsonSchema.getValidator(schema as any, validator) +export const getValidator = ( + schema: TObject | TIntersect | TUnion, + validator: Ajv +): Validator => jsonSchema.getValidator(schema as any, validator) /** * Returns compiled validation functions to validate data for the `create`, `update` and `patch`