from pydantic import BaseModel, Field, EmailStr from typing import Optional from datetime import datetime from enum import Enum class UserRoles(str, Enum): admin = "admin" lawyer = "lawyer" client = "client" class UserBase(BaseModel): first_name: str = Field(..., min_length=1, max_length=100) last_name: str = Field(..., min_length=1, max_length=100) email: EmailStr = Field(..., max_length=255) phone_number: str = Field(..., max_length=20) role: UserRoles bar_number: str = Field(..., max_length=50) is_active: bool = True address: Optional[str] = None profile_picture: str = Field(..., max_length=255) class UserCreate(UserBase): password: str = Field(..., min_length=8, max_length=255) class Config: schema_extra = { "example": { "first_name": "John", "last_name": "Doe", "email": "john@example.com", "password": "securepass123", "phone_number": "+1234567890", "role": "lawyer", "bar_number": "BAR123456", "is_active": True, "address": "123 Main St, City", "profile_picture": "http://example.com/profile.jpg" } } class UserResponse(UserBase): id: int last_login: Optional[datetime] = None created_at: datetime updated_at: datetime class Config: orm_mode = True