Question: Is it possible to return all validation errors for one field?
See original GitHub issueDescribe 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:
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:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top 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 >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 FreeTop 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
Top GitHub Comments
@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!
Hmm, let me test this out and get a codesandbox