-
Notifications
You must be signed in to change notification settings - Fork 145
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
Feature request: add safeParse option #2204
Comments
Will this value be enabled by default? |
No. |
This issue is now closed. Please be mindful that future comments are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so. |
This is now released under v2.1.0 version! |
Use case
If you don't want Zod to throw errors when validation fails, use
.safeParse
. This method returns an object containing either the successfully parsed data or a ZodError instance containing detailed information about the validation problems.There are cases when customers used
safeParse
in their previous implementation and expect to have this option in the powertools parser utility. Thus, we should add an option to that will determine wether we callparse
orsafeParse
internally in built-in schemas andenvelopes
Solution/User Experience
We can expand the
ParserOptions
by addingsafeParse
argument, and call it directly on decoratorThis would also require an expansion of the envelopes to support
safeParse
option.Alternative solutions
No response
Acknowledgment
Future readers
Please react with 👍 and your use case to help us understand customer demand.
The text was updated successfully, but these errors were encountered: