"""Validation schemas for config operations."""

from typing import Any

from pydantic import field_validator

from .base import Base


class InputToConfig(Base):
    """Validation schema for config input data."""

    customer: str
    crawl_origin_tickets_storage_account_name: str
    crawl_origin_data_full_cosmos_db_name: str
    InputToTicket_validated_at: str

    @field_validator(
        "customer",
        "crawl_origin_tickets_storage_account_name",
        "crawl_origin_data_full_cosmos_db_name",
        "InputToTicket_validated_at",
        mode="after",
    )
    @classmethod
    def validate_string_fields(cls, v: str) -> str:
        return Base.validate_non_empty_string(v)


class ConfigToCrawl(InputToConfig):
    """Validation schema for config-to-crawl operations."""

    config_source: str
    compute_target: str
    data_target: str
    subscriber: str
    InputToConfig_validated_at: str
    config_execution_row: dict[str, Any]

    @field_validator(
        "config_source",
        "compute_target",
        "data_target",
        "subscriber",
        "InputToConfig_validated_at",
        mode="after",
    )
    @classmethod
    def validate_string_fields(cls, v: str) -> str:
        return Base.validate_non_empty_string(v)

    @field_validator("config_execution_row", mode="after")
    @classmethod
    def validate_dict_fields(cls, v: dict[str, Any]) -> dict[str, Any]:
        return Base.validate_non_empty_dict(v)
