normalize the field value in the filter
422115
function normFilter(model, filter, fieldName) {
  if (!filter) return null;

  let result = {},
    fields = model.def.fields;
  for (const key in filter) {
    if (key === '$and' || key === '$or') { // {$and:[]}, {$or: []}
      const subfilters = [];
      for (const j in filter[key]) {
        const sub = normFilter(model, filter[key][j]);
        if (!sub) continue;
        subfilters.push(sub);
      }
      if (subfilters.length > 0) result[key] = subfilters;
      continue;
    }
    if (key.charAt(0) === '$') { // key is an operator, {op: value}
      if (!fieldName) {
        throw new QueryError(model.name, 'no field for operator %s in filter', key);
      }
      if (!fields[fieldName]) {
        throw new QueryError(model.name, 'nonexistent field %s in filter', fieldName);
      }
      result[key] = fields[fieldName].normalize(filter[key], { query: true });
      continue;
    }

    // key is a field, {field: value}, {field: {op: value, ...}}
    fieldName = key;
    const field = fields[key];
    if (!field) throw new QueryError(model.name, 'nonexistent field %s in filter', key);
    if (field.props.filterRedirect) {
      const proxyFields = field.props.filterRedirect.replace(/\s+/g, '').split(',');
      const proxyFilter = { $or: [] };
      for (const pi in proxyFields) {
        const proxyFieldName = proxyFields[pi];
        const fieldProxyFilter = {};
        fieldProxyFilter[proxyFieldName] = filter[key];
        proxyFilter.$or.push(fieldProxyFilter);
      }
      Object.assign(result, normFilter(model, proxyFilter));
      continue;
    }

    // {field: {op: value, ...}}
    if (util.isPlainObject(filter[key])) {
      result[fieldName] = normFilter(model, filter[key], fieldName);
      continue;
    }

    // {field: value}, value is not string
    let value = filter[key];
    if (typeof value !== 'string') { // array, date, int, float, bool, etc
      result[fieldName] = field.normalize(value, { query: true });
      continue;
    }

    // {field: value}, value is a plain string
    value = value.trim();
    if (!(value.substring(0, 1) === '{' && value.substr(-1) === '}')) {
      result[fieldName] = field.normalize(value, { query: true });
      continue;
    }

    // {field: value}, value is string and may contain a json object which is a query filter too
    const jsonExpr = null;
    try {
      eval('jsonExpr = '+value);//eslint-disable-line
    } catch (e) {}// eslint-disable-line no-empty
    if (!jsonExpr) { // parse fails, treat as plain string
      result[fieldName] = field.normalize(value, { query: true });
    } else {
      const jsonFilter = {};
      for (const jk in jsonExpr) {
        if (jk.charAt(0) === '$') { // expand {op:val} to {field:{op: val}}
          jsonFilter[fieldName] = {};
          jsonFilter[fieldName][jk] = jsonExpr[jk];
        } else { // {field: value}
          jsonFilter[jk] = jsonExpr[jk];
        }
      }
      result = Object.assign(result, normFilter(model, jsonFilter, fieldName));
    }
  }

  if (util.isEmptyObject(result)) return null;
  return result;
}
244025
def filter(self, field_name, field_value):
        
        self.filters.append((field_name, field_value))
        return self
1298495
def normalize_value(text):
    
    result = text.replace('\n', ' ')
    result = re.subn('[ ]{2,}', ' ', result)[0]
    return result
446581
function normalizeValue(value, info) {
  if (typeof value === 'number') {
    value = String(value)
  } else if (typeof value === 'boolean') {
    value = info.attribute
  } else if (typeof value === 'object' && 'length' in value) {
    value = (info.commaSeparated ? commaSeparated : spaceSeparated)(value)
  }

  return value
}
383105
protected function normalizeFields()
    {
        $normalizedFields = [];
        foreach ($this->fields as $key => $field) {
            if ($this->isNumber($key)) {
                $direction = 1;
                if (substr($field, 0, 1) === '-') {
                    $direction = -1;
                }
                $normalizedFields[ltrim($field, '-+')] = $direction;
            } else {
                $normalizedFields[$key] = $field;
            }
        }
        $this->fields = $normalizedFields;
    }
1305505
function parseFilter(model, filter) {
  let merged = null;
  if (util.isEmptyObject(model.def.filter)) {
    merged = filter;
  } else if (util.isEmptyObject(filter)) {
    merged = model.def.filter;
  } else {
    merged = { $and: [model.def.filter, filter] };
  }
  return builder.normFilter(model, merged);
}
492016
def clean(self, value):
        """"""
        if not value:
            return None

        # if any value exists, then add "0" as a placeholder to the remaining
        # values.
        if isinstance(value, list) and any(value):
            for i, item in enumerate(value):
                if not item:
                    value[i] = '0'

        return super(MultipleDecimalField, self).clean(value)
54331
def _ni(field, filter_value):
        
        valid = False
        if field not in filter_value:
            valid = True
        return valid
1166309
def pre_filter(self):
        
        if self._name in self.PRE_FILTER_FIELDS:
            if not self._value:
                return '"not=${}"'.format(self.PRE_FILTER_FIELDS[self._name])
            else:
                val = self._value
                if self._exact:
                    val = val.copy().pop()
                return r'"string.contains_i=${},\"{}\""'.format(
                       self.PRE_FILTER_FIELDS[self._name], val.replace('"', r'\\\"'))
        return ''
1246426
def normalize(value)
      case value
      when Hash
        normalize_hash(value)
      when Array
        normalize_array(value)
      else
        value
      end
    end
1302760
def normalize(value):
    
    if value and isinstance(value, bytes):
        value = value.decode('utf-8')
    return value
189593
def strip_filter(value):
    '''
    

    '''
    if isinstance(value, basestring):
        value = bleach.clean(value, tags=ALLOWED_TAGS,
                             attributes=ALLOWED_ATTRIBUTES, 
                             styles=ALLOWED_STYLES, strip=True)
    return value
766945
def normalize_field(field)
      default_value = if field.default?
                        { default: field.default }
                      else
                        {}
                      end
      super.merge(default_value)
    end
1188411
def addFilter(self, field, value):
        
        if "<" not in value or ">" not in value or ".." not in value:
            value = ":" + value

        if self.__urlFilters:
            self.__urlFilters += "+" + field + str(quote(value))
        else:
            self.__urlFilters += field + str(quote(value))
383283
def normalize_value(val):
    
    
    if val is not None:
        if val.lower() == 'false':
            val = False
        elif val.lower() == 'true':
            val = True
    
    return val
1185496
def _normalize(value):
        
        if hasattr(value, 'value'):
            value = value.value
        if value is not None:
            value = long(value)
        return value
1041133
function normalizeClauses (conf) {
  const output = {};
  const validPath = Object.keys(conf).filter(path => Array.isArray(conf[path]));
  validPath.forEach(path => {
    const validClauses = conf[path].filter(c => c.value !== '');
    if (validClauses.length) {
      output[path] = validClauses;
    }
  });
  return output;
}