"""Validation schemas for crawler operations."""

from typing import Any

from pydantic import field_validator

from .base import Base
from .proxy import ProxyToCrawler


class InputToCrawler(ProxyToCrawler):
    """
    Validation schema for crawler input data.

    Note: No additional timestamp field required here.
    The ValidationHandler adds InputToCrawler_validated_at when this class is validated.
    """


class CrawlerToData(InputToCrawler):
    """Validation schema for crawler-to-data operations."""

    scraping_result: dict[str, Any]
    InputToCrawler_validated_at: str

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

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