import click


def validate_scheduled_reset_period(ctx, param, value):
    """Ensure that a valid value for scheduled reset period is used."""

    periods = [
        "Never Reset",
        "Daily",
        "Weekly",
        "Fortnightly",
        "Monthly",
        "Bi-Monthly",
        "Quarterly",
        "Every 6 months",
        "Annual",
    ]

    if value:
        for period in periods:
            if value.lower() == period.lower():
                return period

        raise click.BadParameter(
            "The refresh token period must be one of the allowed values "
            "(Never reset, Daily, Weekly, Fortnightly, Monthly "
            "Bi-Monthly, Quarterly, Every 6 months, Annual).",
            param=param,
        )

    return value