We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When I make a form using a zod schema with a transformed field, tanstack-form seems to ignore the transform part.
zod
tanstack-form
https://stackblitz.com/edit/vitejs-vite-jxdfvr?file=src%2FApp.tsx
I would expect to see the form value be
{ foo: 'new value' }
Windows 11 Chrome Latest
react-form
0.13.6
5.3.2
import { createFormFactory } from '@tanstack/react-form' import { zodValidator } from '@tanstack/zod-form-adapter' import { z } from 'zod' const schema = z.object( { foo: z.string().transform( () => 'new value' ), } ) type FormOutput = z.output<typeof schema> const formFactory = createFormFactory( { validatorAdapter: zodValidator, defaultValues: { foo: '', } as FormOutput, } ) export default function Page () { const form = formFactory.useForm() const values = form.useStore( x => x.values ) return <form.Provider> <form> <div style={{ display: 'flex', gap: '1rem', flexDirection: 'column', alignItems: 'start', }}> <form.Field name='foo' validators={{ onChange: schema.shape.foo, }} > {field => <label style={{ display: 'flex', flexDirection: 'column', alignItems: 'start', gap: '0.25rem', }}> <div>{field.name}:</div> <input id={field.name} name={field.name} value={field.state.value} autoComplete='off' onChange={e => { field.handleChange( e.target.value ) }} /> </label>} </form.Field> <span> form value: <pre style={{ display: 'inline' }}>{JSON.stringify( values )}</pre> </span> <span> form value should be: <pre style={{ display: 'inline' }}>{JSON.stringify( { foo: 'new value' } )}</pre> </span> </div> </form> </form.Provider> }
The text was updated successfully, but these errors were encountered:
As-of today, we do not support Zod transforms. We'll likely need to explore this space as a dedicated feature - might not make it into 1.x
Sorry, something went wrong.
Actually, I realize this work is captured in #418, let's move the convo over there
No branches or pull requests
Describe the bug
When I make a form using a
zod
schema with a transformed field,tanstack-form
seems to ignore the transform part.Your minimal, reproducible example
https://stackblitz.com/edit/vitejs-vite-jxdfvr?file=src%2FApp.tsx
Steps to reproduce
zod
schemaExpected behavior
I would expect to see the form value be
Platform
Windows 11
Chrome Latest
Tanstack Form adapter
react-form
TanStack Form version
0.13.6
TypeScript version
5.3.2
Additional context
The text was updated successfully, but these errors were encountered: