Matching fields example (ie. Passwords)
See original GitHub issueI’m struggling with getting a Yup validation working to ensure two fields match (in this case, password and password confirm).
validationSchema: Yup.object().shape({
password: Yup.string()
.required('Password is required'),
passwordConfirm: Yup.mixed().test('match', 'Passwords do not match', function (password) {
return password === this.parent.passwordConfirm
}).required('Password confirm is required')
}),
I’m new to Formik & Yup (and relatively new to JS generally). Really appreciate any pointers.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:27 (2 by maintainers)
Top Results From Across the Web
Password Matching using JavaScript - GeeksforGeeks
It is the simple method to verify the password matches. First password is stored into a password1 variable and confirm password is stored...
Read more >Confirm password validation in JavaScript - javatpoint
To create a valid password, both the password and confirm password fields value must be matched. First one, we will check for a...
Read more >SSO (Saved Passwords) Apps: Custom Formulas
Example : Password for all users is apple. Type in: apple. Fields, Insert the whole contents of a field in Clever. Example: Password...
Read more >Test Cases for Password and Forgot Password Functionality
Presenting test cases for password and forgot password fields. These test cases will help you in your interviews as well as in the...
Read more >Remember passwords and fill out web forms for Internet ...
Learn how to fill in forms on websites and remember online passwords automatically with AutoComplete in Internet Explorer.
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
FYI folks this has gotten easier in the most recent version of yup.
oneOf
and notOneOf` now support refsYup doesn’t make this common usecase as easy as it should. Here’s how I’ve gotten this to work (a slight modification of code in https://github.com/jquense/yup/issues/97)
…
then in your validationSchema: