feat: add set phone
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user