From fb0425f932460a21a2152a2a5a56006f32d03d2f Mon Sep 17 00:00:00 2001 From: Rud1095 Date: Sat, 22 Jun 2024 11:22:02 +0000 Subject: [PATCH] Owerwrite regular conndions for correct working Closed #35434 Updated validations.py python script. Fixed the behavior of validate_user function in validations.py. --- Course3/Lab4/validations.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) mode change 100644 => 100755 Course3/Lab4/validations.py diff --git a/Course3/Lab4/validations.py b/Course3/Lab4/validations.py old mode 100644 new mode 100755 index b18de65a2e..a070063230 --- a/Course3/Lab4/validations.py +++ b/Course3/Lab4/validations.py @@ -13,12 +13,18 @@ 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-Za-z][\.a-zA-Z_]*$', username): return False # Usernames can't begin with a number if username[0].isnumeric(): 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