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.

How to check username and password format?

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jquensecommented, Jul 8, 2020

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 (using test())

0reactions
jquensecommented, Jul 9, 2020

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

Read more comments on GitHub >

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

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