parent
fb63ef413c
commit
a9123dd9e3
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@hono/zod-validator': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
add: Async zod support
|
|
@ -24,8 +24,8 @@ export const zValidator = <
|
||||||
schema: T,
|
schema: T,
|
||||||
hook?: Hook<z.infer<T>, E, P>
|
hook?: Hook<z.infer<T>, E, P>
|
||||||
): MiddlewareHandler<E, P, V> =>
|
): MiddlewareHandler<E, P, V> =>
|
||||||
validator(target, (value, c) => {
|
validator(target, async (value, c) => {
|
||||||
const result = schema.safeParse(value)
|
const result = await schema.safeParseAsync(value)
|
||||||
|
|
||||||
if (hook) {
|
if (hook) {
|
||||||
const hookResult = hook({ data: value, ...result }, c)
|
const hookResult = hook({ data: value, ...result }, c)
|
||||||
|
|
Loading…
Reference in New Issue