"""Shared base Pydantic model for the domain layer.

All domain models that share the standard configuration should inherit from
``DomainBaseModel`` instead of ``pydantic.BaseModel`` directly.  This ensures
the shared ``model_config`` is defined in exactly one place and that any future
change to the configuration is automatically propagated to every consumer.
"""

from pydantic import BaseModel, ConfigDict

__all__ = ["DomainBaseModel"]


class DomainBaseModel(BaseModel):
    """Base class for all standard domain-layer Pydantic models.

    Provides the shared ``model_config`` that was previously duplicated across
    every model file in the domain layer:

    - ``str_strip_whitespace``: leading/trailing whitespace is stripped from
      all ``str`` fields on assignment and validation.
    - ``validate_assignment``: field assignments after construction are
      validated just like constructor arguments.
    - ``arbitrary_types_allowed``: disabled — all field types must be
      Pydantic-compatible to keep the domain layer clean.
    - ``populate_by_name``: models can be constructed using either the Python
      field name or the JSON alias.
    - ``use_enum_values``: enum fields are stored and serialised as their
      underlying primitive values rather than as enum instances.
    """

    model_config = ConfigDict(
        str_strip_whitespace=True,
        validate_assignment=True,
        arbitrary_types_allowed=False,
        populate_by_name=True,
        use_enum_values=True,
    )
