From 0ac5f9838b390a201f46f1a164506e3f1404092b Mon Sep 17 00:00:00 2001 From: Dawit Ayele Date: Tue, 7 Jan 2025 13:46:55 -0800 Subject: [PATCH 1/2] First commit message Closes: #1 Updated validations.py python script. Fixed the behavior of validate_user function in validations.py. --- Course3/Lab4/validations.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Course3/Lab4/validations.py b/Course3/Lab4/validations.py index b18de65a2e..4389bfd193 100644 --- a/Course3/Lab4/validations.py +++ b/Course3/Lab4/validations.py @@ -13,8 +13,8 @@ def validate_user(username, minlen): if len(username) < minlen: return False # Usernames can only use letters, numbers, dots and underscores - if not re.match('^[a-z0-9._]*$', username): - return False + if not re.match('^[a-zA-Z][a-z0-9._]*$', username): + return False # Usernames can't begin with a number if username[0].isnumeric(): return False @@ -22,3 +22,7 @@ def validate_user(username, minlen): +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 From f2a29053a0afe472003122aff389b6a41ab63a72 Mon Sep 17 00:00:00 2001 From: Dawit Ayele Date: Tue, 7 Jan 2025 14:32:54 -0800 Subject: [PATCH 2/2] Closes: #1 Updated validations.py python script. Fixed the behavior of validate_user function in validations.py. --- Course3/Lab4/validations.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Course3/Lab4/validations.py b/Course3/Lab4/validations.py index 4389bfd193..6b1be5e509 100644 --- a/Course3/Lab4/validations.py +++ b/Course3/Lab4/validations.py @@ -13,6 +13,7 @@ def validate_user(username, minlen): if len(username) < minlen: return False # Usernames can only use letters, numbers, dots and underscores + # username doesnot start with an letter if not re.match('^[a-zA-Z][a-z0-9._]*$', username): return False # Usernames can't begin with a number