def _validate_field(param, fields):
    """ Ensure the sortable field exists on the model """

    if param.field not in fields:
        raise InvalidQueryParams(**{
            'detail': 'The sort query param value of "%s" is '
                      'invalid. That field does not exist on the '
                      'resource being requested.' % param.raw_field,
            'links': LINK,
            'parameter': PARAM,
        })
Ensure the sortable field exists on the model