from quart_imp.auth import is_username_valid
is_username_valid(
username: str,
allowed: t.Optional[t.List[t.Literal["all", "dot", "dash", "under"]]] = None
) -> bool
Checks if a username is valid.
Valid usernames can only include letters, numbers, ., -, and _ but cannot begin or end with the last three mentioned.
is_username_valid("username", allowed=["all"])
Output:
username : WILL PASS : True
user.name : WILL PASS : True
user-name : WILL PASS : True
user_name : WILL PASS : True
_user_name : WILL PASS : False
is_username_valid("username", allowed=["dot", "dash"])
Output:
username : WILL PASS : True
user.name : WILL PASS : True
user-name : WILL PASS : True
user-name.name : WILL PASS : True
user_name : WILL PASS : False
_user_name : WILL PASS : False
.user.name : WILL PASS : False