"""Fleet validators — Phase 10.2."""
from __future__ import annotations

from app.validators.foundation import validate_non_empty


def validate_fleet_name(name: str) -> str:
    return validate_non_empty(name, "name")


def validate_vehicle_type_name(name: str) -> str:
    return validate_non_empty(name, "name")


def validate_plate_number(plate: str | None) -> str | None:
    if plate is None or not str(plate).strip():
        return None
    value = str(plate).strip()
    if len(value) > 32:
        from shared.exceptions import AppError

        raise AppError(
            "شماره پلاک بیش از حد طولانی است",
            status_code=422,
            error_code="plate_too_long",
        )
    return value
