fix: Async zod support. (#175)

* add: Async zod support.

* add: Missing changeset.
pull/179/head
Luis Bizarro 2023-09-25 21:20:41 +01:00 committed by GitHub
parent fb63ef413c
commit a9123dd9e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -0,0 +1,5 @@
---
'@hono/zod-validator': patch
---
add: Async zod support

View File

@ -24,8 +24,8 @@ export const zValidator = <
schema: T,
hook?: Hook<z.infer<T>, E, P>
): MiddlewareHandler<E, P, V> =>
validator(target, (value, c) => {
const result = schema.safeParse(value)
validator(target, async (value, c) => {
const result = await schema.safeParseAsync(value)
if (hook) {
const hookResult = hook({ data: value, ...result }, c)