Yup array error not showing up
See original GitHub issueDescribe the bug
react-hook-form does not register/notice a validation error when a similar yup schema is used: array.of(...).min(1)
To Reproduce
Select and remove an option from the react-select dropdown and notice that react-form-hook’s error object does not have an error for min(1)
and returns true for isValid
when the value is an empty array (= invalid).
Also notice that yup correctly returns false
for the isValidSync
check when I pass the current state of the form (from watch()
). I think this confirms that the problem is with react-hook-form and not yup.
Expected behavior An error should be raised that the array needs at least one item.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Yup schema validation with arrays doesnt display the error ...
I am trying to do simple validation on my form( react Formal 0.28.5). Please see the schema I use below for validation. The...
Read more >FieldArray
To address this, FieldArray s only report errors for array itself. Meaning arrayHelpers.add() will check if the min for "friends" is correct, but...
Read more >How to use the yup.array function in yup - Snyk
How to use the yup.array function in yup. To help you get started, we've selected a few yup examples, based on popular ways...
Read more >Yup Email Validation: String Schema Code Examples
When you call schema.isValid on a Yup array field, it will only return true if all of the elements in the array are...
Read more >Yup + Formik Dynamic Array Of Object form validation - Medium
Dynamic Array of objects with Formik Yup Validation. ... Each field has validation and error messages. I did not explain this because I...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You are absolutely correct. Thank you very much for your time helping me and thanks for creating this awesome package!
no worries @vassbence thanks for reporting the issue and the investigation. 👍