validation.py 689 B

123456789101112131415161718192021222324252627
  1. """Validation utilities."""
  2. import re
  3. def validate_email(email: str) -> bool:
  4. """Validate email format."""
  5. pattern = r'^[^\s@]+@[^\s@]+\.[^\s@]+$'
  6. return bool(re.match(pattern, email))
  7. def validate_password(password: str) -> bool:
  8. """Validate password strength."""
  9. if len(password) < 8:
  10. return False
  11. if not re.search(r'[A-Z]', password):
  12. return False
  13. if not re.search(r'[a-z]', password):
  14. return False
  15. if not re.search(r'[0-9]', password):
  16. return False
  17. return True
  18. def validate_task_title(title: str) -> bool:
  19. """Validate task title."""
  20. return bool(title and len(title.strip()) >= 1 and len(title) <= 200)