H
Hono7mo ago
fOfer

zValidator not coercing types correctly

"@hono/zod-validator": "0.2.2",
"hono": "4.4.10",
"@hono/zod-validator": "0.2.2",
"hono": "4.4.10",
No description
No description
8 Replies
fOfer
fOferOP7mo ago
When I coerce the query to a number, Hono infers the type as Record<string, string> Is there a way to get the correct types without having to extract the zod schema?
Joaquim Ley
Joaquim Ley7mo ago
You should change from: c.req.query() to c.req.valid('query') Reference: - https://hono.dev/docs/guides/validation
Validation - Hono
Ultrafast web framework for Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, Node.js, and others. Fast, but not only fast.
fOfer
fOferOP7mo ago
Thanks a lot
YAGPDB.xyz
YAGPDB.xyz7mo ago
The tickets system is disabled for this server. Enable it at: https://yagpdb.xyz/manage/1011308539819597844/tickets/settings.
Aditya Mathur
Aditya Mathur7mo ago
@Nico seems like this is not working
YAGPDB.xyz
YAGPDB.xyz7mo ago
The tickets system is disabled for this server. Enable it at: https://yagpdb.xyz/manage/1011308539819597844/tickets/settings.
Nico
Nico7mo ago
That’s a different command I haven’t set up a / command yet
András
András6mo ago
Somehow related - when creating an RPC client (according to https://hono.dev/docs/guides/rpc#server) the app types will still contain query params as string instead of numbers in this case (even they're specified correctly with zValidator). Is there something that needs to be configured additionally, or is it a bug/limitation?
RPC - Hono
Ultrafast web framework for Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, Node.js, and others. Fast, but not only fast.

Did you find this page helpful?