Replies: 1 comment 7 replies
-
Is this depend field validation? React Hook Form focus at a input at a time. you will need to |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello! I'm not sure I'm right on this.
I'm using yup as a validation scheme. Yup has a .when( 'inputName', { is: 'someValue', then: yup.string().required() } ) feature, but when the inputName is no longer 'someValue' the error message is still shown. I'm guessing it's because react-hook-form only triggers a watch() of some sort on the required input name... at least until the validation is satisfied.
In this codesandbox, if the lastName is "hello", the firstName is required, but when lastName is not 'hello', error message still exists. Maybe something I have to do in RHF's validationResolver?
Codesandbox
Beta Was this translation helpful? Give feedback.
All reactions