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

Improve Zod integration #1210

Open
radekmie opened this issue Jan 15, 2023 · 6 comments
Open

Improve Zod integration #1210

radekmie opened this issue Jan 15, 2023 · 6 comments
Labels
Area: Bridge Affects some of the bridge packages Bridge: Zod Affects the uniforms-bridge-zod package Type: Feature New features and feature requests
Milestone

Comments

@radekmie
Copy link
Contributor

Since we added Zod integration in #1169, there were a few open topics that we can finally address:

  1. Error messages. These can be now configured using ZodErrorMap and we should show an example of that in the docs and the playground.
  2. Labels. There's a feature request for adding a .label(string) function to a schema (Add a label function as like yup colinhacks/zod#1767) but in the meantime, we could use .describe(string).
    • To be ready for the .label to get released, it should be a flag on the bridge whether the .description should be used as a label.
  3. Async schemas. There's no way of detecting whether we should use async validation or not, so (safeParse throws a generic Error, source) we should have a flag on the bridge deciding it.
@radekmie radekmie added Type: Feature New features and feature requests Area: Bridge Affects some of the bridge packages Bridge: Zod Affects the uniforms-bridge-zod package labels Jan 15, 2023
@radekmie radekmie added this to the v4.0 milestone Jan 15, 2023
@github-project-automation github-project-automation bot moved this to Needs triage in Open Source Jan 15, 2023
@Rishabhg71
Copy link

Rishabhg71 commented Jan 16, 2023

@radekmie can I add label feature?

@radekmie
Copy link
Contributor Author

@RG7279805 Definitely! If you'd need help, feel free to file a draft PR first.

@Rishabhg71
Copy link

Rishabhg71 commented Jan 17, 2023

@radekmie I have tried to add that label function in ZodType
but it doesn't seem to be the best way since .label() has to be first in the chain
z.string().label().min(2) - labels will work for min condition but not for invalid_type or required condition

I have made a draft where I add a label in RawCreateParams
and then it gets available in this._def.label
which can be passed down further
addIssueToContext -> makeIssue -> defaultErrorMap labels can be used here

one problem tho label has to be passed everywhere in addIssueToContext

I am sorry if I did something wrong I hope you overlook it since it's my first commit in open source

current draft : https://github.com/RG7279805/zod/tree/label-in-raw-params
will create a PR after confirmation

@radekmie
Copy link
Contributor Author

@RG7279805 I think we've misunderstood a little 😅 I meant the usage of it in uniforms, not adding a feature of Zod. In any case, I already saw you've raised it also in Zod's repo, so that's fine.

@Rishabhg71
Copy link

@radekmie yeah it was my mistake 😃

@radekmie radekmie modified the milestones: v4.0, v4.x Jan 20, 2023
@radekmie radekmie modified the milestones: v4.x, v4.0 Feb 3, 2023
@radekmie radekmie moved this from Needs triage to To do in Open Source Feb 3, 2023
@dj-fiorex
Copy link

I think that i opened an issue about Zod that could be integrated here #1292

@kestarumper kestarumper modified the milestones: v4.0, v4.x Apr 7, 2024
@kestarumper kestarumper moved this from To do to On Hold in Open Source Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Bridge Affects some of the bridge packages Bridge: Zod Affects the uniforms-bridge-zod package Type: Feature New features and feature requests
Projects
Status: On Hold
Development

No branches or pull requests

4 participants