fix(zod-validator): convert `TypedResponse` to `Response` in hook (#116)

* fix(zod-validator): convert `TypedResponse` to `Response` in hook

* changeset
pull/117/head
Yusuke Wada 2023-08-19 00:15:03 +09:00 committed by GitHub
parent a5a0692c3a
commit c271b6d502
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View File

@ -0,0 +1,5 @@
---
'@hono/zod-validator': patch
---
fix(zod-validator): convert TypedResponse to Response in hook

View File

@ -36,14 +36,14 @@ export const zValidator = <
if (hook) {
const hookResult = hook({ data: value, ...result }, c)
if (
hookResult &&
(hookResult instanceof Response ||
hookResult instanceof Promise ||
'response' in hookResult)
) {
if (hookResult) {
if (hookResult instanceof Response || hookResult instanceof Promise) {
return hookResult
}
if ('response' in hookResult) {
return hookResult.response
}
}
}
if (!result.success) {