Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: New error map API #3618

Open
wants to merge 25 commits into
base: v4
Choose a base branch
from
Open

RFC: New error map API #3618

wants to merge 25 commits into from

Conversation

colinhacks
Copy link
Owner

@colinhacks colinhacks commented Jul 3, 2024

RFC: Error maps

General comments can go below. Leave specific comments in the "Files changed" interface.

View the formatted RFC here: https://github.com/colinhacks/zod/blob/v4-rfc-error-maps/rfcs/v4-error-maps.md

  export type ZodErrorMap = (
    issue: ZodIssueOptionalMessage,  // includes `input` field to replace `ctx.data`
+   /** @deprecated */
    ctx: { defaultError: string; data: any }
- ) => { message: string };
+ ) => { message: string } | string | undefined;

My full-time work on Zod 4, including the design & implementation of this proposal, is supported by Clerk. Don't roll your own auth. 🫶

clerk logo

@colinhacks colinhacks changed the title RFC: Error maps RFC: New error map API Jul 3, 2024
@donaldpipowitch
Copy link

As you touch this area in zod 4 (thanks for working on this), could this maybe be officially added as well? #3212
It works right now, it just needs a type cast. It would be nice to know that the lib itself treats the actual error message as a black box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants