T
TanStack13mo ago
constant-blue

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
stormy-gold
stormy-gold13mo 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(),
})
harsh-harlequin
harsh-harlequin13mo 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?