Skip to content

Feature request/question: Support for generating Zod validator objects when doing type inference #295

@adevine

Description

@adevine

Hello! I just wanted to say this is a truly awesome project! I haven't played with it much yet but reading through the docs it seems like the perfect compliment and the one "missing piece" to my favorite SQL library, Slonik.

My question/feature request:

Slonik lets you do runtime-type validation using Zod validators. Seeing as how this library can generate the Typescript definitions in a sql<{ ... }> tag, it seems then it would also be possible to have similar code that generates a Zod validator that could be used in a sql.type(...generated Zod object goes here...) tag. I love using Zod validators with Slonik, the one downside is that they can be time-consuming/tedious to write manually, but looking through this library it seems like all of the underlying type-analysis pieces are here that would make in relatively straightforward to create a Zod object instead of a TypeScript type.

I wasn't sure if this question belongs better here or on the Slonik project, but I saw @gajus posted some issues here so thought maybe he could give his thoughts on whether this is a good idea. I didn't want to think of this as a formal feature request yet, just interested if you thought this was a workable idea to begin with.

Again, thanks for a fantastic project!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions