HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/aigenerator/AI-LG-backend/Ai_logo_generation/authorization/validators.py
import re
from django.core.exceptions import ValidationError


def validate_password_strength(value):
    conditions = [
        len(value) >= 8,                         # Minimum length 8
        re.search(r'[A-Z]', value),              # At least one uppercase letter
        re.search(r'[a-z]', value),              # At least one lowercase letter
        re.search(r'\d', value),                 # At least one digit
        re.search(r'[!@#$%^&*(),.?":{}|<>]', value)  # At least one special character
    ]
    
    if not all(conditions):
        raise ValidationError(
            "Password must contain at least 8 characters, including an uppercase letter, a lowercase letter, a digit, and a special character."
        )