From a02ccfdcd59e45882baea7f9e137dc90a0acb746 Mon Sep 17 00:00:00 2001 From: Sanjay Developer Date: Tue, 21 Apr 2020 05:17:14 +0000 Subject: [PATCH] Closes: #1 Updated validations.py python script. Fixed the behavior of validate_user function in validations.py. --- Course3/Lab4/validations.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Course3/Lab4/validations.py b/Course3/Lab4/validations.py index b18de65a2e..f132b93737 100644 --- a/Course3/Lab4/validations.py +++ b/Course3/Lab4/validations.py @@ -13,7 +13,7 @@ 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): + if not re.match('^[a-z][a-z0-9._]*$', username): return False # Usernames can't begin with a number if username[0].isnumeric(): @@ -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