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

class InformationBase(BaseModel):
    title: str = Field(..., min_length=1, max_length=200)
    content: str = Field(..., min_length=1)
    category: str = Field(default="general")
    is_published: bool = Field(default=True)
    priority: int = Field(default=0, ge=0)

class InformationCreate(InformationBase):
    pass

class InformationUpdate(BaseModel):
    title: Optional[str] = Field(None, min_length=1, max_length=200)
    content: Optional[str] = Field(None, min_length=1)
    category: Optional[str] = None
    is_published: Optional[bool] = None
    priority: Optional[int] = Field(None, ge=0)

class InformationResponse(InformationBase):
    id: int
    created_at: datetime
    updated_at: datetime
    
    class Config:
        from_attributes = True
