"""Routing validators — Phase 10.6."""
from __future__ import annotations

from shared.exceptions import AppError


def validate_route_code_present(code: str) -> str:
    code = str(code).strip()
    if not code:
        raise AppError(
            "کد مسیر الزامی است",
            status_code=422,
            error_code="route_code_required",
        )
    return code


def validate_stop_sequence(sequence: int) -> int:
    if sequence < 0:
        raise AppError(
            "ترتیب توقف نامعتبر است",
            status_code=422,
            error_code="invalid_stop_sequence",
        )
    return sequence
