"""Pydantic schemas for API request/response validation."""

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


class CardBase(BaseModel):
    """Base card schema."""
    title: str = Field(..., min_length=1, max_length=200, description="Card title")
    description: Optional[str] = Field(None, max_length=1000, description="Card description")


class CardCreate(CardBase):
    """Schema for creating a new card."""
    
    model_config = {
        "json_schema_extra": {
            "examples": [
                {
                    "title": "会议通知",
                    "description": "明天下午2点在一号会议室"
                }
            ]
        }
    }


class CardUpdate(BaseModel):
    """Schema for updating an existing card."""
    title: Optional[str] = Field(None, min_length=1, max_length=200, description="Card title")
    description: Optional[str] = Field(None, max_length=1000, description="Card description")
    
    model_config = {
        "json_schema_extra": {
            "examples": [
                {
                    "title": "更新后的标题",
                    "description": "更新后的描述"
                }
            ]
        }
    }


class CardResponse(CardBase):
    """Schema for card response."""
    id: int
    created_at: datetime
    updated_at: datetime
    
    class Config:
        from_attributes = True
