Skip to content

Commit

Permalink
Updated validations.py to ensure username does not start with . or _
Browse files Browse the repository at this point in the history
Closes: google#36108
  • Loading branch information
salmanriazsyed committed Nov 19, 2024
1 parent 33be82d commit f8ec31d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Course3/Lab4/validations.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ def validate_user(username, minlen):
# Usernames can't begin with a number
if username[0].isnumeric():
return False

# Usernames can't begin with dots or underscores
if username[0] == '.' or username[0] == '_':
return False
return True



print(validate_user("blue.kale", 3)) # True
print(validate_user(".blue.kale", 3)) # Currently True, should be False
print(validate_user("red_quinoa", 4)) # True
print(validate_user("_red_quinoa", 4)) # Currently True, should be False

0 comments on commit f8ec31d

Please sign in to comment.