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

Mention parse options in the documentation #3876

Open
mike-4040 opened this issue Dec 1, 2024 · 2 comments
Open

Mention parse options in the documentation #3876

mike-4040 opened this issue Dec 1, 2024 · 2 comments

Comments

@mike-4040
Copy link

Schema method .parse() accepts an optional second argument params.

type ParseParams = {
    path: (string | number)[];
    errorMap: ZodErrorMap;
    async: boolean;
};

I've found it very useful, especially errorMap property.

The usage is described in https://github.com/colinhacks/zod/blob/main/ERROR_HANDLING.md.

Unfortunately, in the .parse() documentation the params is not mentioned, see https://zod.dev/?id=parse

Screenshot 2024-12-01 at 11 00 49 AM

I think this just hide a very useful feature.

Would be nice to add params to .parse() documentation, or at least mention it and link ERROR_HANDLING.md

@colinhacks
Copy link
Owner

colinhacks commented Dec 10, 2024

Hm yeah, it's definitely an oversight to not include errorMap anywhere in the main README. I think I was hesitant to document error maps too visibly since they're a comparatively advanced feature and might feel intimidating to some users. I'll work on this.

The other two params aren't really intended for direct use and should probably be hidden from the public API.

@mike-4040
Copy link
Author

Thanks, errorMap is a super convenient feature.

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

No branches or pull requests

2 participants