"""
Pydantic schemas for Phase 1.4 profile endpoints (PUT /profiles/me).

All fields are Optional to support partial updates (PATCH-like behavior on a PUT route).
When a field is provided, the same validation rules as signup apply.
"""
from typing import Optional

from pydantic import Field

from app.schemas.auth import PHONE_REGEX
from app.schemas.base import CamelCaseModel


class UpdateProfileRequest(CamelCaseModel):
    """
    Payload to update the current user's profile.

    All 5 fields are optional. Only fields explicitly provided will be updated.
    Use `model_dump(exclude_unset=True)` in the service to get only the provided fields.

    Empty strings are rejected (would fail min_length / regex validation).
    Setting a field to NULL is not currently supported (out of scope for Sprint 8B).
    """
    firstname: Optional[str] = Field(default=None, min_length=1, max_length=50)
    lastname: Optional[str] = Field(default=None, min_length=1, max_length=50)
    phone: Optional[str] = Field(default=None, pattern=PHONE_REGEX)
    profession: Optional[str] = Field(default=None, min_length=2, max_length=80)
    city: Optional[str] = Field(default=None, min_length=2, max_length=50)
