@hono/zod-validator
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -9,3 +9,6 @@ "use strict"; | ||
const hookResult = hook({ data: value, ...result }, c); | ||
if (hookResult instanceof Response || hookResult instanceof Promise) { | ||
if (hookResult && | ||
(hookResult instanceof Response || | ||
hookResult instanceof Promise || | ||
'response' in hookResult)) { | ||
return hookResult; | ||
@@ -12,0 +15,0 @@ } |
@@ -1,4 +0,4 @@ | ||
import type { Context, MiddlewareHandler, Env, ValidationTargets } from 'hono'; | ||
import type { Context, MiddlewareHandler, Env, ValidationTargets, TypedResponse } from 'hono'; | ||
import type { z, ZodError } from 'zod'; | ||
type Hook<T, E extends Env, P extends string> = (result: { | ||
export type Hook<T, E extends Env, P extends string, O = {}> = (result: { | ||
success: true; | ||
@@ -10,3 +10,3 @@ data: T; | ||
data: T; | ||
}, c: Context<E, P>) => Response | Promise<Response> | void | Promise<Response | void>; | ||
}, c: Context<E, P>) => Response | Promise<Response> | void | Promise<Response | void> | TypedResponse<O> | Promise<TypedResponse<O>> | Promise<TypedResponse<O> | void>; | ||
export declare const zValidator: <T extends z.ZodType<any, z.ZodTypeDef, any>, Target extends keyof ValidationTargets, E extends Env, P extends string, V extends { | ||
@@ -18,3 +18,2 @@ in: { [K in Target]: z.input<T>; }; | ||
out: { [K_3 in Target]: z.output<T>; }; | ||
}>(target: Target, schema: T, hook?: Hook<z.TypeOf<T>, E, P> | undefined) => MiddlewareHandler<E, P, V>; | ||
export {}; | ||
}>(target: Target, schema: T, hook?: Hook<z.TypeOf<T>, E, P, {}> | undefined) => MiddlewareHandler<E, P, V>; |
@@ -6,3 +6,6 @@ import { validator } from 'hono/validator'; | ||
const hookResult = hook({ data: value, ...result }, c); | ||
if (hookResult instanceof Response || hookResult instanceof Promise) { | ||
if (hookResult && | ||
(hookResult instanceof Response || | ||
hookResult instanceof Promise || | ||
'response' in hookResult)) { | ||
return hookResult; | ||
@@ -9,0 +12,0 @@ } |
{ | ||
"name": "@hono/zod-validator", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Validator middleware using Zod", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3965
57