TanStackT
TanStack8mo ago
6 replies
wet-aqua

Validation schema withtout default value keys

Is there a way to use a validation schema with missing default values keys :

Something like this :

const userSchema = z.object({
age: z.number().gte(13, 'You must be 13 to make an account'),
})

function App() {
const form = useForm({
defaultValues: {
age: 0,
name: 'toto',
},
validators: {
onChange: userSchema,
},
})
return (
<div>
<form.Field
name="age"
children={(field) => {
return <>{/* ... */}</>
}}
/>
</div>
)
}

If i do this, i have on error on the onChange validator
Was this page helpful?