import re


def normalize_phone(phone: str) -> str:
    """
    Canonical phone format:
    - Always starts with +
    - Digits only after +
    """
    phone = phone.strip()

    # Remove everything except digits
    digits = re.sub(r"\D", "", phone)

    if not digits:
        raise serializers.ValidationError("Invalid phone number.")

    return f"+{digits}"
