2025-06-19 17:47:24 +00:00

28 lines
932 B
Python

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