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

feat(fetch): add safeParse function #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

otomir23
Copy link

@otomir23 otomir23 commented Mar 8, 2025

Almost all supported type parsers (zod, valibot, valita) have two options for validating: throwing errors and returning a Result union object. Currently @fuman/fetch only provides the former option, which is harder to use if you want to implement custom error handling or stick to explicit flow control.

This PR addresses this issue and adds safeParse function to FfetchTypeProvider that uses the Result-based validating. yup sadly doesn't have a way to execute validation without throwing, so a simple try-catch wrapper was implemented.

@teidesu
Copy link
Owner

teidesu commented Mar 8, 2025

lgtm 🙏

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