Username validation
The rules for naming a user are:
- Usernames can contain both lowercase and uppercase characters.
- Usernames can contain alphanumeric characters.
- Usernames can contain underscore and hyphens.
- They cannot contain spaces.
- They cannot contain two underscores, two hyphens or two spaces in a row.
- They cannot contain an underscore, hyphen or space at the start or the end.
These are valid usernames:
- username
- userName
- user.name
- username4
- user_name
- user-name
These are invalid usernames:
- username (there is space in the beginning)
- _username
- -username
- user__name
- user name
- user–name
- username_
- username (there is space in the end)
- username-
- user name