@hono/zod-validator
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -10,5 +10,5 @@ "use strict"; | ||
if (hook) { | ||
const hookResult = hook({ data: value, ...result }, c); | ||
const hookResult = await hook({ data: value, ...result }, c); | ||
if (hookResult) { | ||
if (hookResult instanceof Response || hookResult instanceof Promise) { | ||
if (hookResult instanceof Response) { | ||
return hookResult; | ||
@@ -24,5 +24,4 @@ } | ||
} | ||
const data = result.data; | ||
return data; | ||
return result.data; | ||
}); | ||
exports.zValidator = zValidator; |
@@ -10,3 +10,3 @@ import type { Context, MiddlewareHandler, Env, ValidationTargets, TypedResponse, Input } from 'hono'; | ||
data: T; | ||
}, c: Context<E, P>) => Response | Promise<Response> | void | Promise<Response | void> | TypedResponse<O>; | ||
}, c: Context<E, P>) => Response | void | TypedResponse<O> | Promise<Response | void | TypedResponse<O>>; | ||
type HasUndefined<T> = undefined extends T ? true : false; | ||
@@ -13,0 +13,0 @@ export declare const zValidator: <T extends z.ZodType<any, z.ZodTypeDef, any>, Target extends keyof ValidationTargets, E extends Env, P extends string, In = z.input<T>, Out = z.output<T>, I extends Input = { |
@@ -7,5 +7,5 @@ import { validator } from 'hono/validator'; | ||
if (hook) { | ||
const hookResult = hook({ data: value, ...result }, c); | ||
const hookResult = await hook({ data: value, ...result }, c); | ||
if (hookResult) { | ||
if (hookResult instanceof Response || hookResult instanceof Promise) { | ||
if (hookResult instanceof Response) { | ||
return hookResult; | ||
@@ -21,4 +21,3 @@ } | ||
} | ||
const data = result.data; | ||
return data; | ||
return result.data; | ||
}); |
{ | ||
"name": "@hono/zod-validator", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Validator middleware using Zod", | ||
@@ -5,0 +5,0 @@ "type": "module", |
220206
4931
63