import click


def validate_bandwidth_unit(ctx, param, value):
    """Ensure that a valid value for bandwidth unit is used."""

    units = [
        "Byte",
        "Kilobyte",
        "Megabyte",
        "Gigabyte",
        "Terabyte",
        "Petabyte",
        "Exabyte",
        "Zettabyte",
        "Yottabyte",
    ]

    if value:
        for unit in units:
            if value.lower() == unit.lower():
                return unit

        raise click.BadParameter(
            "Bandwidth unit must be one of the allowed values "
            "(Byte, Kilobyte, Megabyte, Gigabyte, Terabyte, Petabyte, "
            "Exabyte, Zettabyte, Yottabyte).",
            param=param,
        )

    return value