T
TanStack16mo ago
vicious-gold

Set a default validator.

99% of our forms are going to use a zodValidator is there a way to set a global default?
2 Replies
extended-salmon
extended-salmon16mo ago
What are you expecting from this global default? Using zod only requires adding this line in your useForm declaration once
const form = useForm({
...
validatorAdapter: zodValidator(),
})
const form = useForm({
...
validatorAdapter: zodValidator(),
})
modern-teal
modern-teal16mo ago
Maybe you could export the zodValidator() somewhere as export const validatorAdapter = zodValidator() that would shorten the one line you'll have to add and only change one import statement at the top of your file(s)
const form = useForm({
...
validatorAdapter,
})
const form = useForm({
...
validatorAdapter,
})

Did you find this page helpful?