Skip to content

Zod 4 / Standard Schema support #197

Description

@oxc

Is your feature request related to a problem? Please describe.
I am now using Zod 4 in my project, and I get peer dependency mismatch warnings for command-zod and event-type-zod

The code works still fine, but it would be good to have official support and get rid of the warnings.

Note

While investigating potential breakage, I was surprised to learn that ZodCommand does not use the schemas in any way to validate the input. While I can figure out some good reasons behind this decision, it's really unexpected, and IMHO deserves a mention in the README.
EDIT: Just found #136 and #175

Describe the solution you'd like
The naive solution would be to just bump the peer dependencies. However, while reading Zod migration guides and notes for library authors, I noticed this section:

If you're building a library that accepts user-defined schemas to perform black-box validation, you may not need to integrate with Zod specifically. Instead look into Standard Schema. It's a shared interface implemented by most popular validation libraries in the TypeScript ecosystem (see the full list), including Zod.

This sounds like a very reasonable choice for castore types, regardless of whether they do validation or not. This way, a event-type-standard-schema and command-standard-schema could support all kinds of typed validators, not just zod.

I would like to get your input, on how to best move forward with this. I would be happy to prepare a PR for either way, but I would like to avoid wasted work.

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