"""
Pydantic v2 schemas for the Marketing Who We Serve category CMS (INDL-53).

Write schemas explicitly whitelist the fields a client may set. `id`,
`category_key`, `badge_label`, `sort_order`, and timestamps are never
accepted from the client -- the 4 categories are structurally fixed and
only ever created via migration seed data (see PRD's Security Checklist
A08/API3).

Length/required checks use plain `Optional[str]` / `Optional[List[str]]`
fields (no Pydantic `Field(min_length=...)` constraints) so the router can
raise the exact copy from the PRD's Validation Rules table (e.g. "Heading
is required"). Pydantic v2 prefixes `field_validator` `ValueError`s with
"Value error, " and this codebase's `validation_error_handler` does not
strip that prefix (see `src/core/handlers/errors.py`), so business-rule
messages are raised via `src/core/exceptions.ValidationError` in the
router instead -- the same pattern already used by the FAQ CMS (INDL-52)
in this router.
"""
from __future__ import annotations

from typing import List, Optional

from pydantic import BaseModel, ConfigDict


# ---------------------------------------------------------------------------
# Site-admin — requests (explicit field whitelisting — A08 / API3)
# ---------------------------------------------------------------------------

class UpdateWhoWeServeCategoryRequest(BaseModel):
    """Body for PATCH /site-admin/who-we-serve/{category_key}. Only heading/intro/points
    are bindable — never id/category_key/badge_label/sort_order/timestamps (A08/API3)."""

    model_config = ConfigDict(extra="forbid")

    heading: Optional[str] = None
    intro: Optional[str] = None
    points: Optional[List[str]] = None


# ---------------------------------------------------------------------------
# Public — responses (deliberately narrower than the admin shape; no id/
# sort_order/timestamps -- data minimization for the anonymous endpoint)
# ---------------------------------------------------------------------------

class PublicWhoWeServeCategoryResponse(BaseModel):
    category_key: str
    badge_label: str
    heading: str
    intro: str
    points: List[str]

    model_config = ConfigDict(from_attributes=True)
