quart-imp/docs/_md/v1/quart_imp_auth-is_username_valid.md
David Carmichael bfcc49dd8d feat: docs
2024-08-16 15:09:07 +01:00

1.0 KiB

Menu = quart_imp.auth/is_username_valid
Title = is_username_valid - quart_imp.auth
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.

Example "all":
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
Example "dot", "dash":

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