From d906e924d8846b53806506ab79882fdffad71c00 Mon Sep 17 00:00:00 2001 From: santa Date: Thu, 25 Feb 2021 15:15:41 +0000 Subject: [PATCH] Closes: #1 Updated 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..c632ccf0f5 100644 --- a/Course3/Lab4/validations.py +++ b/Course3/Lab4/validations.py @@ -4,6 +4,9 @@ def validate_user(username, minlen): """Checks if the received username matches the required conditions.""" + char_check = re.search(r"^([a-zA-Z])", username) + if char_check is None: + return False if type(username) != str: raise TypeError("username must be a string") if minlen < 1: @@ -22,3 +25,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