Skip to content

Commit

Permalink
fix(zod-validator): convert TypedResponse to Response in hook (#116)
Browse files Browse the repository at this point in the history
* fix(zod-validator): convert `TypedResponse` to `Response` in hook

* changeset
  • Loading branch information
yusukebe authored Aug 18, 2023
1 parent a5a0692 commit c271b6d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/poor-apricots-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hono/zod-validator': patch
---

fix(zod-validator): convert TypedResponse to Response in hook
14 changes: 7 additions & 7 deletions packages/zod-validator/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down

0 comments on commit c271b6d

Please sign in to comment.