from pydantic import BaseModel, EmailStr, Field from typing import Optional from datetime import datetime class UserBase(BaseModel): """ Base schema with common user attributes. """ email: EmailStr full_name: Optional[str] = None is_active: Optional[bool] = True class UserCreate(UserBase): """ Schema for creating a new user, includes password. """ password: str = Field(..., min_length=8) class UserUpdate(BaseModel): """ Schema for updating an existing user. """ email: Optional[EmailStr] = None full_name: Optional[str] = None password: Optional[str] = Field(None, min_length=8) is_active: Optional[bool] = None class UserInDBBase(UserBase): """ Base schema for user data from the database. """ id: int created_at: datetime updated_at: datetime class Config: from_attributes = True class User(UserInDBBase): """ Schema for user data to return to client. """ pass class UserInDB(UserInDBBase): """ Schema for user data with hashed_password field. """ hashed_password: str