from __future__ import annotations

import re

_UPLOAD_ID_RE = re.compile(r"^up_[a-zA-Z0-9_-]{10,30}$")


def validate_upload_id(raw: str) -> tuple[bool, str]:
    """Returns (ok, error_message)."""
    if not raw:
        return False, "uploadId must be a non-empty string."

    if not _UPLOAD_ID_RE.match(raw):
        return False, "uploadId format is invalid. Expected: up_ followed by 10-30 alphanumeric characters."

    return True, ""
