import click


def validate_profile(context, param, value):
    """
    Validates existance of profile.
    Returns the profile name if it exists; otherwise throws BadParameter
    """
    if value in context.obj.configuration.profiles():
        return value
    else:
        raise click.BadParameter("\"%s\" was not found" % value)