Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

RFC: Support number, boolean, Date in query params #44

@jqhoogland

Description

@jqhoogland

Right now it's not possible to have z.number()'s in your input schema for GET requests.
That makes sense since query params are strings (so you get an error like Input parser key: "limit" must be ZodString).

But often (I'm thinking especially of pagination), you need numbers. Right now, you can recreate similar functionality with z.string().transform((s) => parseInt(s), but it's not ideal since you lose, for example, Zod's built-in min/max validation.

At a minimum, this deserves a mention in the documentation. If we're feeling more ambitious, we can introduce autoconversions to number/date for common types.

I'm happy to open a PR, but first wanted to hear what you think, @jlalmes.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions