Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions backend/src/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import uuid
import re
from beanie import Document, Indexed
from pydantic import BaseModel, Field, StringConstraints, field_validator, model_validator
from enum import Enum
Expand Down Expand Up @@ -111,6 +112,11 @@ class UserCreate(BaseModel):
phone: Annotated[str, StringConstraints(strip_whitespace=True, pattern=r'^\+?[0-9]{10,15}$')]
password: str

@field_validator('phone', mode='after')
def normalize_phone(cls, v: str) -> str:
if v:
return re.sub(r'(?!^\+)[^\d]', '', v)
return v
@field_validator('date_of_birth')
@classmethod
def validate_birth_date(cls, value: date) -> date:
Expand Down