E5EE fix(typebox): allow TUnion<TObject[]> inside getValidator by daffl · Pull Request #3262 · feathersjs/feathers · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions packages/typebox/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
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'
Expand All @@ -17,8 +26,10 @@ export type TDataSchemaMap = {
* @param validator The AJV validation instance
* @returns A compiled validation function
*/
export const getValidator = <T = any, R = T>(schema: TObject | TIntersect, validator: Ajv): Validator<T, R> =>
jsonSchema.getValidator(schema as any, validator)
export const getValidator = <T = any, R = T>(
schema: TObject | TIntersect | TUnion<TObject[]>,
validator: Ajv
): Validator<T, R> => jsonSchema.getValidator(schema as any, validator)

/**
* Returns compiled validation functions to validate data for the `create`, `update` and `patch`
Expand Down
0