"""Base validation schema with shared logic."""

from typing import Any

from pydantic import BaseModel, ConfigDict


class Base(BaseModel):
    """Base validation schema with shared configuration and methods."""

    model_config = ConfigDict(strict=True)

    @property
    def name(self) -> str:
        return self.__class__.__name__

    @classmethod
    def get_field_validation_status(cls) -> dict[str, str]:
        """
        Get validation status for all fields.

        Returns a dict mapping field names to 'validated' or 'unvalidated'
        based on whether they have field validators attached.
        """
        all_fields = set(cls.model_fields.keys())
        validated_fields: set[str] = set()

        decorators = cls.__pydantic_decorators__
        for validator_info in decorators.field_validators.values():
            validated_fields.update(validator_info.info.fields)

        return {
            field: "validated" if field in validated_fields else "unvalidated"
            for field in sorted(all_fields)
        }

    @classmethod
    def validate_non_empty_string(cls, v: str) -> str:
        if not v or not v.strip():
            msg = "Field cannot be empty or whitespace only"
            raise ValueError(msg)
        return v

    @classmethod
    def validate_non_empty_dict(cls, v: dict[str, Any]) -> dict[str, Any]:
        if not v:
            msg = "Dict field cannot be empty"
            raise ValueError(msg)
        return v
