feat: add set phone

This commit is contained in:
2026-05-14 21:45:43 +03:00
parent 6465807394
commit 75362b07ae
10 changed files with 105 additions and 29 deletions

View File

@@ -1,6 +1,5 @@
import re
from pydantic import BaseModel, field_validator
from src.application.domain.exceptions import ApplicationException
class SetPhoneRequest(BaseModel):
@@ -12,6 +11,6 @@ class SetPhoneRequest(BaseModel):
cleaned = re.sub(r'[\s\-\(\)]', '', v)
pattern = r'^(\+7|8)\d{10}$'
if not re.match(pattern, cleaned):
raise ApplicationException(message='Invalid Russian phone number', status_code=429)
raise ValueError('Invalid Russian phone number')
normalized = '+7' + cleaned[-10:]
return normalized
return normalized