Files
evo-sync/web/schemas.py
mguschin 951c12a208 Add user registration and auth web app
FastAPI + Jinja2 + MariaDB web application with registration,
login, profile, password reset, and email confirmation flows.
All UI in Russian. Styled with Evotor brand colors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 22:01:58 +03:00

53 lines
2.0 KiB
Python

import re
def validate_registration(data: dict) -> list[str]:
errors = []
if not data.get("first_name", "").strip():
errors.append("Введите имя")
if not data.get("last_name", "").strip():
errors.append("Введите фамилию")
email = data.get("email", "").strip()
if not email or not re.match(r"^[^@]+@[^@]+\.[^@]+$", email):
errors.append("Введите корректный email")
phone = data.get("phone", "").strip()
if not phone or not re.match(r"^\+?[\d\s\-()]{7,20}$", phone):
errors.append("Введите корректный телефон")
password = data.get("password", "")
if len(password) < 8:
errors.append("Пароль должен быть не менее 8 символов")
if password != data.get("password_confirm", ""):
errors.append("Пароли не совпадают")
return errors
def validate_login(data: dict) -> list[str]:
errors = []
if not data.get("email", "").strip():
errors.append("Введите email")
if not data.get("password", ""):
errors.append("Введите пароль")
return errors
def validate_reset_password(data: dict) -> list[str]:
errors = []
password = data.get("password", "")
if len(password) < 8:
errors.append("Пароль должен быть не менее 8 символов")
if password != data.get("password_confirm", ""):
errors.append("Пароли не совпадают")
return errors
def validate_profile(data: dict) -> list[str]:
errors = []
if not data.get("first_name", "").strip():
errors.append("Введите имя")
if not data.get("last_name", "").strip():
errors.append("Введите фамилию")
phone = data.get("phone", "").strip()
if not phone or not re.match(r"^\+?[\d\s\-()]{7,20}$", phone):
errors.append("Введите корректный телефон")
return errors