def validate_fields(ctx, param, value): valid = Display.build_fields().keys() possible = value.split(',') if value else [] for field in possible: if field not in valid: raise click.BadParameter( 'Field {} is not a valid field! Use {}'.format( field, ','.join(valid))) return possible
def validate_sort(ctx, param, value): if value and value not in Display.build_fields().keys(): raise click.BadParameter( 'Sort parameter {} is not a valid field!'.format(value)) return value