from __future__ import annotations

from pydantic import BaseModel, ConfigDict, Field


class SubcategoriaBase(BaseModel):
    nome: str = Field(min_length=1, max_length=255)
    categoriaId: str | None = Field(default=None, description="ID da categoria (Appwrite document id)")


class SubcategoriaCreate(SubcategoriaBase):
    pass


class SubcategoriaUpdate(BaseModel):
    nome: str | None = Field(default=None, min_length=1, max_length=255)
    categoriaId: str | None = None


class SubcategoriaOut(BaseModel):
    id: str
    nome: str
    categoriaId: str | None = None
    createdAt: str
    updatedAt: str

    model_config = ConfigDict(from_attributes=True)
