from pydantic import BaseModel, Field from datetime import datetime from typing import Optional class TodoBase(BaseModel): title: str = Field(..., title="The title of the todo", min_length=1) description: Optional[str] = Field(None, title="The description of the todo") completed: bool = Field(False, title="Whether the todo is completed") class TodoCreate(TodoBase): pass class TodoUpdate(BaseModel): title: Optional[str] = Field(None, title="The title of the todo", min_length=1) description: Optional[str] = Field(None, title="The description of the todo") completed: Optional[bool] = Field(None, title="Whether the todo is completed") class TodoInDB(TodoBase): id: int created_at: datetime updated_at: Optional[datetime] = None class Config: from_attributes = True class Todo(TodoInDB): pass