What are the valid characters in usernames?

1 points
Asked by:

I need to create authentication validation and I need to decide what characters we will allow to in username. For now I think:

  • letters
  • numbers
  • dots

Is there a problem with using underscore (_) and dash (-)?
Or it should be avoided to allow users to use such characters?
If yes, why?

1 answers
2 points
Answered by:

Everything depends where would you like to use this username later, how sent and have it easly readable during transfering and storing.

In my opinion following characters ._-0-9a-zA-Z are good because make username clear. It is easy later even to use username in request parameter ?username=my-user-name for rows filtering/searching and link is very clear.

Only one additional limitation I would like to add is to do not let for any user to create login that starts, ends or contains in direct sibling following characters ._-.

If you want to integrate it with some service like gmail I recommend to look at google documentations.


0 comments Add comment
Hey 👋
Would you like to know what we do?
  • Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.