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.

Question: Is it possible to return all validation errors for one field?

See original GitHub issue

Describe the bug Looking to create a realtime password validation in react using Yup validation.

Related Issue: https://github.com/react-hook-form/resolvers/issues/26

In yup, I have the schema like this:

const passwordSchema = yup.object().shape({
  password: yup
    .string()
    .required()
    .min(8)
    .matches(RegExp('(.*[a-z].*)'), 'Lowercase')
    .matches(RegExp('(.*[A-Z].*)'), 'Uppercase')
    .matches(RegExp('(.*\\d.*)'), 'Number')
    .matches(RegExp('[!@#$%^&*(),.?":{}|<>]'), 'Special'),
});

Is it possible on validate to get ALL the errors in an array. Right now, using RFH and yupResolver I get: Screen Shot 2020-07-13 at 7 47 39 PM

Ideally, i would like something that RFH does on validate where it would show all the criteria that is failing, not just the first one of the .matches()

I appreciate any guidance or thoughts. Thanks in advance.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sngregcommented, Jul 14, 2020

@jquense - Thanks for clarifying this, i made a quick codesandbox and was able to verify that you are correct, when aboutEarly is on it returns all of the errors

https://codesandbox.io/s/nice-brown-61nzg

Will close out my question!

0reactions
sngregcommented, Jul 14, 2020

Hmm, let me test this out and get a codesandbox

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to go through all Pydantic validators even if one fails, and ...
You can't raise multiple Validation errors/exceptions for a specific field, in the way you demonstrate in your question.
Read more >
Form-Field Validation: The Errors-Only Approach
When the user first submits the page, the entire page is reloaded, but with indications of validation errors. A message at the top...
Read more >
Reporting | Validation errors explained - FEC
Explanations for error messages returned when using the validator for electronic filings with the Federal Election Commission.
Read more >
Form Validation Errors - how to track them and what to do ...
If your website has forms, it's more than likely that users filling them in see a variety of form validation errors. Some of...
Read more >
Form and field validation - Django documentation
If you detect multiple errors during a cleaning method and wish to signal all of them to the form submitter, it is possible...
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