diff --git a/packages/validathor/src/schemas/tuple.ts b/packages/validathor/src/schemas/tuple.ts index 375141c..a3cf1c8 100644 --- a/packages/validathor/src/schemas/tuple.ts +++ b/packages/validathor/src/schemas/tuple.ts @@ -2,7 +2,7 @@ import type { Parser } from '@/types' import { assert, assertType, TypeError } from '@/utils' import { ERROR_CODES } from '@/utils/errors/errorCodes' -const isParser = (input: unknown): input is Parser => { +const isParser = (input: unknown): input is T => { return input !== null && typeof input === 'object' && 'parse' in input } @@ -27,12 +27,15 @@ export const tuple = []>( ) return value.reduce((result: T[], item: T, index) => { + const schemaItem = schema[index] + assertType>( - schema[index], - isParser, + schemaItem, + isParser>, new TypeError(message?.type_error || ERROR_CODES.ERR_TYP_0000.message()), ) - result.push(schema[index].parse(item)) + + result.push(schemaItem.parse(item)) return result }, []) },