question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Yup array error not showing up

See original GitHub issue

Describe 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.

Codesandbox

Expected behavior An error should be raised that the array needs at least one item.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
vassbencecommented, Nov 28, 2020

You are absolutely correct. Thank you very much for your time helping me and thanks for creating this awesome package!

0reactions
bluebill1049commented, Nov 28, 2020

no worries @vassbence thanks for reporting the issue and the investigation. 👍

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found