Zod validator - conditional validation with refine() #597
-
I'm trying to achieve some conditional validation based on an other field. I've seen in the zod doc that the refine() method would be the go-to for what I'm trying to achieve but I can't figure out how to integrate it to tanstack form validation. Here is some sample code of what I'm trying to achieve:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Right now we don't support conditional validation sadly. It's on our short list of things to do prior to 1.x - stay tuned! |
Beta Was this translation helpful? Give feedback.
-
This is now supported here: https://tanstack.com/form/latest/docs/framework/react/guides/linked-fields You can do z.refine inside of onChange with onChangeListenTo |
Beta Was this translation helpful? Give feedback.
Right now we don't support conditional validation sadly. It's on our short list of things to do prior to 1.x - stay tuned!