from __future__ import annotations

from typing import Any, Dict, List

ALLOWED_FIELD_TYPES = frozenset({"text", "number", "enum"})


def validate_field_type(field_type: str) -> bool:
    return field_type in ALLOWED_FIELD_TYPES


def normalize_field_type(field_type: str) -> str:
    """Return field_type if allowed, else downgrade to text (seed/import)."""
    return field_type if validate_field_type(field_type) else "text"


def field_type_error_detail() -> Dict[str, Any]:
    return {
        "hint": "field_type must be text|number|enum",
        "allowed": sorted(ALLOWED_FIELD_TYPES),
    }
