middleware icon indicating copy to clipboard operation
middleware copied to clipboard

Status code used in the third argument of zValidator is not inferred on the client side

Open mayone-du opened this issue 8 months ago • 4 comments

I have the following code. When trying to handle branching on the client side based on res.status, it always ends up being 200. Is there any documentation or solution regarding this issue?

const sampleRoute = new Hono().get(
  '/sample',
  zValidator(
    'json',
    z.object({
      keyword: z.string().min(1),
    }),
    (result, c) => {
      if (!result.success) {
        return c.json({ error: 'error!' }, 400)
      }
    }
  ),
  async (c) => {
    return c.json({ data: 'data' }, 200)
  }
)

in client スクリーンショット 2024-06-16 13 04 46

mayone-du avatar Jun 16 '24 04:06 mayone-du