18 lines
472 B
Python
18 lines
472 B
Python
from pydantic import BaseModel, Field
|
|
from datetime import date
|
|
|
|
class TodoCreate(BaseModel):
|
|
title: str = Field(..., max_length=255)
|
|
description: str | None = Field(None, max_length=255)
|
|
due_date: date | None = Field(None)
|
|
status: str = Field(..., in=["pending", "completed"])
|
|
|
|
class TodoResponse(BaseModel):
|
|
id: int
|
|
title: str
|
|
description: str | None
|
|
due_date: date | None
|
|
status: str
|
|
|
|
class Config:
|
|
from_attributes = True |