From 0bf37e7ad96d020e8587a57895392f9d93958bbb Mon Sep 17 00:00:00 2001 From: Naxdri Date: Mon, 14 Apr 2025 10:13:11 +0000 Subject: [PATCH] Closes: #1 Update validations.py python script. Fixed the behavior of validate_user function in validations.py --- Course3/Lab4/validations.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Course3/Lab4/validations.py b/Course3/Lab4/validations.py index b18de65a2e..e77a2946e3 100644 --- a/Course3/Lab4/validations.py +++ b/Course3/Lab4/validations.py @@ -18,7 +18,14 @@ def validate_user(username, minlen): # Usernames can't begin with a number if username[0].isnumeric(): return False + # Username can't begin with none letter as '-', '_', '.' etc + if not re.match('[a-zA-Z]', 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