Skip to content

Commit cf9df96

Browse files
authored
fix(typebox): allow TUnion<TObject[]> inside getValidator (#3262)
1 parent c619ab2 commit cf9df96

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

packages/typebox/src/index.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
import { Type, TObject, TInteger, TOptional, TSchema, ObjectOptions, TIntersect } from '@sinclair/typebox'
1+
import {
2+
Type,
3+
TObject,
4+
TInteger,
5+
TOptional,
6+
TSchema,
7+
ObjectOptions,
8+
TIntersect,
9+
TUnion
10+
} from '@sinclair/typebox'
211
import { jsonSchema, Validator, DataValidatorMap, Ajv } from '@feathersjs/schema'
312

413
export * from '@sinclair/typebox'
@@ -17,8 +26,10 @@ export type TDataSchemaMap = {
1726
* @param validator The AJV validation instance
1827
* @returns A compiled validation function
1928
*/
20-
export const getValidator = <T = any, R = T>(schema: TObject | TIntersect, validator: Ajv): Validator<T, R> =>
21-
jsonSchema.getValidator(schema as any, validator)
29+
export const getValidator = <T = any, R = T>(
30+
schema: TObject | TIntersect | TUnion<TObject[]>,
31+
validator: Ajv
32+
): Validator<T, R> => jsonSchema.getValidator(schema as any, validator)
2233

2334
/**
2435
* Returns compiled validation functions to validate data for the `create`, `update` and `patch`

0 commit comments

Comments
 (0)