From 023fdeadc0390b3394f6f66886de75ee835b5625 Mon Sep 17 00:00:00 2001 From: dickys11 Date: Thu, 25 Feb 2021 14:20:43 +0000 Subject: [PATCH] Closes: #1 Update validations.py python script Fixed the behavior of validate_user function in validations.py --- Course3/Lab4/validations.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Course3/Lab4/validations.py b/Course3/Lab4/validations.py index b18de65a2e..01aedf0cb9 100644 --- a/Course3/Lab4/validations.py +++ b/Course3/Lab4/validations.py @@ -12,6 +12,8 @@ def validate_user(username, minlen): # Usernames can't be shorter than minlen if len(username) < minlen: return False + if not re.match('^[a-z0-9]', username): + return False # Usernames can only use letters, numbers, dots and underscores if not re.match('^[a-z0-9._]*$', username): return False @@ -20,5 +22,9 @@ def validate_user(username, minlen): 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)) #Curently True, should be False