Conditional validation on when the checkbox is checked. #3574
Answered
by
logaretm
shankhadevpadam
asked this question in
Q&A
-
I have a field that will be validated if the checkbox is checked and not required if the checkbox is unchecked. https://codesandbox.io/s/vee-yup-conditional-c9fw8?file=/src/App.vue In the sandbox, a phone should be validated if I checked the checkbox but the form should be submitted if the checkbox is unchecked. |
Beta Was this translation helpful? Give feedback.
Answered by
logaretm
Nov 8, 2021
Replies: 1 comment 2 replies
-
Since you are doing your conditionals on a yup schema using |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
logaretm
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since you are doing your conditionals on a yup schema using
when
, theisPhone
should be a<Field>
that exists in the form. You used the nativeinput
element which won't work.https://codesandbox.io/s/vee-yup-conditional-forked-3f49m