2025-05-17 18:53:46 +00:00

38 lines
865 B
Python

from datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field
class TodoBase(BaseModel):
"""Base Todo schema."""
title: str = Field(..., min_length=1, max_length=100)
description: Optional[str] = Field(None, max_length=1000)
completed: bool = False
class TodoCreate(TodoBase):
"""Todo creation schema."""
pass
class TodoUpdate(BaseModel):
"""Todo update schema with all fields optional."""
title: Optional[str] = Field(None, min_length=1, max_length=100)
description: Optional[str] = Field(None, max_length=1000)
completed: Optional[bool] = None
class TodoResponse(TodoBase):
"""Todo response schema."""
id: int
created_at: datetime
updated_at: datetime
class Config:
"""Pydantic config."""
from_attributes = True