from datetime import datetime from typing import Optional from pydantic import BaseModel, Field # Shared properties class TodoBase(BaseModel): title: str = Field(..., min_length=1, max_length=100) description: Optional[str] = Field(None, max_length=1000) completed: bool = False # Properties to receive on Todo creation class TodoCreate(TodoBase): pass # Properties to receive on Todo update class TodoUpdate(BaseModel): title: Optional[str] = Field(None, min_length=1, max_length=100) description: Optional[str] = Field(None, max_length=1000) completed: Optional[bool] = None # Properties shared by models in the DB class TodoInDBBase(TodoBase): id: int created_at: datetime updated_at: Optional[datetime] = None class Config: from_attributes = True # Properties to return to client class Todo(TodoInDBBase): pass