Which middleware has the bug?
zod-validator
What version of the middleware?
0.7.3
What version of Hono are you using?
4.9.8
What runtime/platform is your app running on? (with version if possible)
Bun 1.2.22
What steps can reproduce the bug?
When I use zValidator to validate a JSON request body and set the schema to z.object({ name: z.string() }).partial(), the validation by zValidator is completely bypassed if the request is made without the Content-Type: application/json header and without a request body.
Ideally, zValidator should validate the request body. Even if the request body is an empty object {}, it should still comply with the validation rules of this schema.
This is the reproduction code.
const schema = z.object({ name: z.string() }).partial();
router.post('/test', zValidator('json', schema), (c) => {
const body = c.req.valid('json');
return c.text('ok');
});
// ok
I am using zod 4.1.11. I am not entirely sure if this is a bug or a feature, but it does not quite meet my expectations.
What is the expected behavior?
No response
What do you see instead?
No response
Additional information
No response