Adds auth module
This commit is contained in:
44
services/auth/app/schemas/users.py
Normal file
44
services/auth/app/schemas/users.py
Normal file
@@ -0,0 +1,44 @@
|
||||
# ================================================================
|
||||
# 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
|
||||
tenant_id: Optional[str]
|
||||
role: str
|
||||
created_at: datetime
|
||||
last_login: Optional[datetime]
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
Reference in New Issue
Block a user