Run: black and isort
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import re
|
||||
import logging
|
||||
import re
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ValidationUtils:
|
||||
@staticmethod
|
||||
def validate_email(email: str) -> bool:
|
||||
@@ -10,7 +11,7 @@ class ValidationUtils:
|
||||
return False
|
||||
|
||||
email = email.strip().lower()
|
||||
pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
|
||||
pattern = r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
|
||||
is_valid = bool(re.match(pattern, email))
|
||||
|
||||
if not is_valid:
|
||||
@@ -27,7 +28,7 @@ class ValidationUtils:
|
||||
if len(username) < 3 or len(username) > 25:
|
||||
logger.warning(f"Username length invalid: {len(username)}")
|
||||
return False
|
||||
pattern = r'^[a-zA-Z0-9_]+$'
|
||||
pattern = r"^[a-zA-Z0-9_]+$"
|
||||
is_valid = bool(re.match(pattern, username))
|
||||
if not is_valid:
|
||||
logger.warning(f"Invalid username format: {username}")
|
||||
@@ -40,12 +41,14 @@ class ValidationUtils:
|
||||
errors.append("Password is required")
|
||||
return False, errors
|
||||
if len(password) < 4 or len(password) > 50:
|
||||
errors.append("Password must be at least 4 characters long and must not exceed 128 characters")
|
||||
if not re.search(r'[A-Z]', password):
|
||||
errors.append(
|
||||
"Password must be at least 4 characters long and must not exceed 128 characters"
|
||||
)
|
||||
if not re.search(r"[A-Z]", password):
|
||||
errors.append("Password must contain at least one uppercase letter")
|
||||
if not re.search(r'[a-z]', password):
|
||||
if not re.search(r"[a-z]", password):
|
||||
errors.append("Password must contain at least one lowercase letter")
|
||||
if not re.search(r'\d', password):
|
||||
if not re.search(r"\d", password):
|
||||
errors.append("Password must contain at least one digit")
|
||||
if not re.search(r'[!@#$%^&*(),.?":{}|<>]', password):
|
||||
errors.append("Password must contain at least one special character")
|
||||
@@ -53,4 +56,4 @@ class ValidationUtils:
|
||||
if not is_valid:
|
||||
logger.warning(f"Password validation failed: {errors}")
|
||||
|
||||
return is_valid, errors
|
||||
return is_valid, errors
|
||||
|
||||
Reference in New Issue
Block a user