from typing import Optional
from pydantic import BaseModel, Field, ConfigDict


class LegendBase(BaseModel):
    code: int = Field(..., description="Legend Code (CLAVELEY)")
    description: Optional[str] = Field(
        None, max_length=2000, description="Description")


class LegendCreate(LegendBase):
    pass


class LegendUpdate(BaseModel):
    code: Optional[int] = None
    description: Optional[str] = Field(None, max_length=2000)


class LegendResponse(LegendBase):
    id: int

    model_config = ConfigDict(from_attributes=True)
    tenant_id : int
    company_id : int    
