diff --git a/.changeset/poor-apricots-pay.md b/.changeset/poor-apricots-pay.md new file mode 100644 index 00000000..e24bb7cd --- /dev/null +++ b/.changeset/poor-apricots-pay.md @@ -0,0 +1,5 @@ +--- +'@hono/zod-validator': patch +--- + +fix(zod-validator): convert TypedResponse to Response in hook diff --git a/packages/zod-validator/src/index.ts b/packages/zod-validator/src/index.ts index 8e0bbda7..00f6f250 100644 --- a/packages/zod-validator/src/index.ts +++ b/packages/zod-validator/src/index.ts @@ -36,13 +36,13 @@ export const zValidator = < if (hook) { const hookResult = hook({ data: value, ...result }, c) - if ( - hookResult && - (hookResult instanceof Response || - hookResult instanceof Promise || - 'response' in hookResult) - ) { - return hookResult + if (hookResult) { + if (hookResult instanceof Response || hookResult instanceof Promise) { + return hookResult + } + if ('response' in hookResult) { + return hookResult.response + } } }