Skip to content

Commit

Permalink
chore(validathor): fix type error
Browse files Browse the repository at this point in the history
  • Loading branch information
Kosai106 committed Oct 12, 2024
1 parent f255f39 commit 4000517
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/validathor/src/schemas/tuple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Parser } from '@/types'
import { assert, assertType, TypeError } from '@/utils'
import { ERROR_CODES } from '@/utils/errors/errorCodes'

const isParser = <T>(input: unknown): input is Parser<T> => {
const isParser = <T>(input: unknown): input is T => {
return input !== null && typeof input === 'object' && 'parse' in input
}

Expand All @@ -27,12 +27,15 @@ export const tuple = <T extends Parser<unknown>[]>(
)

return value.reduce((result: T[], item: T, index) => {
const schemaItem = schema[index]

assertType<Parser<T>>(
schema[index],
isParser<T>,
schemaItem,
isParser<Parser<T>>,
new TypeError(message?.type_error || ERROR_CODES.ERR_TYP_0000.message()),
)
result.push(schema[index].parse(item))

result.push(schemaItem.parse(item))
return result
}, [])
},
Expand Down

0 comments on commit 4000517

Please sign in to comment.