From 8120ea6067a73887f8b832b95e58c745b8da96b7 Mon Sep 17 00:00:00 2001 From: Joshua-Etsekson Date: Wed, 9 Apr 2025 20:51:15 +0000 Subject: [PATCH 1/2] Closes: #1 updated the validations.py script. added a test for forbidden first character of username in validate_user function --- Course3/Lab4/validations.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Course3/Lab4/validations.py b/Course3/Lab4/validations.py index b18de65a2e..03fefab457 100644 --- a/Course3/Lab4/validations.py +++ b/Course3/Lab4/validations.py @@ -18,7 +18,13 @@ def validate_user(username, minlen): # Usernames can't begin with a number if username[0].isnumeric(): return False + if re.match('[0-9._]', 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 From febe2c6ca811b854df8419075bb370695b5c519c Mon Sep 17 00:00:00 2001 From: Joshua-Etsekson Date: Wed, 9 Apr 2025 15:15:45 -0700 Subject: [PATCH 2/2] Update validations.py --- Course3/Lab4/validations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Course3/Lab4/validations.py b/Course3/Lab4/validations.py index 03fefab457..0e918757bb 100644 --- a/Course3/Lab4/validations.py +++ b/Course3/Lab4/validations.py @@ -18,7 +18,7 @@ def validate_user(username, minlen): # Usernames can't begin with a number if username[0].isnumeric(): return False - if re.match('[0-9._]', username[0]): + if not re.match('[A-Za-z]', username[0]): return False return True