<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def validate_endpoint(ctx, param, value):
 """Validate endpoint."""

    try:
        config = ctx.obj['config']
    except Exception:
        return

    endpoint = default_endpoint(ctx, param, value)

    if endpoint not in config.get('endpoints', {}):
        raise click.UsageError('Unknown endpoint: {0}'.format(endpoint))

    return endpoint