43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
# ================================================================
|
|
# services/auth/app/schemas/users.py
|
|
# ================================================================
|
|
"""
|
|
User schemas
|
|
"""
|
|
|
|
from pydantic import BaseModel, EmailStr, Field, validator
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
|
|
from shared.utils.validation import validate_spanish_phone
|
|
|
|
class UserUpdate(BaseModel):
|
|
"""User update schema"""
|
|
full_name: Optional[str] = Field(None, min_length=2, max_length=100)
|
|
phone: Optional[str] = None
|
|
language: Optional[str] = Field(None, pattern="^(es|en)$")
|
|
timezone: Optional[str] = None
|
|
|
|
@validator('phone')
|
|
def validate_phone(cls, v):
|
|
"""Validate phone number"""
|
|
if v and not validate_spanish_phone(v):
|
|
raise ValueError('Invalid Spanish phone number')
|
|
return v
|
|
|
|
class UserProfile(BaseModel):
|
|
"""User profile schema"""
|
|
id: str
|
|
email: str
|
|
full_name: str
|
|
phone: Optional[str]
|
|
language: str
|
|
timezone: str
|
|
is_active: bool
|
|
is_verified: bool
|
|
created_at: datetime
|
|
last_login: Optional[datetime]
|
|
|
|
class Config:
|
|
from_attributes = True
|