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

Zod Transform does not work with Standard Schema Resolver #742

Closed
skalidindi opened this issue Feb 12, 2025 · 4 comments
Closed

Zod Transform does not work with Standard Schema Resolver #742

skalidindi opened this issue Feb 12, 2025 · 4 comments
Assignees

Comments

@skalidindi
Copy link

Describe the bug
I wanted to try out the new standard-schema resolver so I swapped it from the zodResolver that I current use. However, I noticed a bug regarding zod transforms where the transform runs but the handleSubmit data returned is not transformed but in its original shape.

To Reproduce

  1. Visit https://stackblitz.com/edit/vitejs-vite-5onrdfps?file=src%2FApp.jsx
  2. Notice the code has a transform statement that should make the submit return a string for the pagerduty field.
  3. However when you click on the submit form button the console shows the value as an object.

Codesandbox link (Required)
Include a codesandbox will help us to investigate the issue quicker.

https://stackblitz.com/edit/vitejs-vite-5onrdfps?file=src%2FApp.jsx

Expected behavior
I expect the same behavior as when I used zodResolver where the value is transformed on submit of the form.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: MacOS
  • Browser Chrome
  • Version Latest

Additional context
N/A

@jorisre jorisre self-assigned this Feb 12, 2025
@jorisre
Copy link
Member

jorisre commented Feb 12, 2025

Hi @skalidindi , thanks for reporting this issue. Some work has been done on the standard resolver, but it hasn't been released yet. Keep an eye on upcoming releases—I’ll make sure this gets addressed.

@skalidindi
Copy link
Author

Hi @jorisre. Thank you for the response. I was not aware that this was not ready for consumption yet. Maybe it is worth updating the docs to make it clear that the standard resolver is not fully ready yet.

@jorisre
Copy link
Member

jorisre commented Feb 26, 2025

Hey @skalidindi , looking at your CSB - can't see any difference in the console.log between zodResolver and standardSchemaResolver. Mind sharing more details on the issue? Thanks!

@skalidindi
Copy link
Author

skalidindi commented Feb 27, 2025

Hey @jorisre actually I think this is fixed in the latest version. However if you want to reproduce, I updated the stackblitz to lock down the version of the library to 4.0.0. In that version using standard-schema I get
{"pagerduty":{"label":"2323","value":"#52343"}} as the result but I am expecting {"pagerduty":"#52343"} which zodResolver gives back.

However, in 4.1.2 I am getting {"pagerduty":"#52343"} consistently using either resolver.

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

No branches or pull requests

2 participants