Files
newz-qwen-9b/backend/schemas/category.py
T

36 lines
743 B
Python

"""
Pydantic schemas for Category model.
"""
from typing import Optional
from pydantic import BaseModel, Field
class CategoryBase(BaseModel):
"""Base category schema."""
name: str = Field(..., min_length=1, max_length=100)
slug: str = Field(..., min_length=1, max_length=100)
class CategoryCreate(CategoryBase):
"""Schema for creating a new category."""
pass
class CategoryUpdate(BaseModel):
"""Schema for updating a category."""
name: Optional[str] = Field(None, min_length=1, max_length=100)
slug: Optional[str] = Field(None, min_length=1, max_length=100)
class CategoryResponse(CategoryBase):
"""Schema for category response."""
id: int
class Config:
from_attributes = True