How to check username and password format?
See original GitHub issueI am using formik to build forms in React Native and Yup is the default validation package for formik.
In the app that I am building, it requires users to put in their email, password, and username. Yup’s email validation works well, but is there a way to do the standard password and username validation? For example, the username shouldn’t include any whitespace.
> const validationSchema = Yup.object().shape({
> email: Yup.string().required().email().label("Email"),
> password: Yup.string().required().min(4).label("Password"),
> username: Yup.string().required().min(5).label("User name"),
> });
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Username and Password Authentication - Auth0
First, you have to check that the user doesn't already exist in the database. Once that's clear, you should again check that their...
Read more >How to match username and password in database in SQL
Create a database with a name check. Now click on SQL and write the query code mentioned below. CREATE TABLE register( id int(10)...
Read more >How To Manage Stored User Names and Passwords on a ...
When you type your user name and password for the resource, and then click to select the Remember my password check box, your...
Read more >Logging in with Usernames and Passwords - Practical UNIX ...
Logging in with Usernames and Passwords Every person who uses a Unix computer should have her own account. An account is identified by...
Read more >Username & Password/Passphrase - CSUSM
Username & Password/Passphrase. UNABLE TO LOG IN TO YOUR ACCOUNT? If you are unable to log in to your account, change your password...
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
yup doesn’t have any special rules for user names or passwords, since they differ wildy depending on use case. You should break up each of their validation requirements into single things like “minimum 8 chars” or “no whitespace” and look for builtin methods that allow that. In general most things can be implemented with one or more
matches
test, which accepts a regular expression. If you aren’t comfortable with regex’s you can also implement the logc via a custom test (usingtest()
)Whiles users might find the google checks adequate that doesn’t make it a helpful default to include unfortunately. Ultimately the yup schema needs to match whatever the backend server implements, which varies wildly depending on use case and product choices. On the other hand implementing what you need in yup should be straightforward and simple once you learn the basics of the library. I do agree that the docs could be reworked to better highlight how to customize behavior