TODO:
 1) inject ?
 2) fields can be removed on client side
197994
def empty_trap_required
      is_human = true
      params.slice(*TheComments.config.empty_inputs).values.each{|v| is_human = (is_human && v.blank?) }

      if !is_human
        @errors << [t('the_comments.trap'), t('the_comments.trap_message')].join(': ')
      end
    end
1117719
function inject(content, opt) {
  var startTag = opt.startTag;
  var endTag = opt.endTag;
  var startMatch;
  var endMatch;

  /**
   * The content consists of:
   *
   * <everything before startMatch>
   * <startMatch>
   * <previousInnerContent>
   * <endMatch>
   * <everything after endMatch>
   */

  while ((startMatch = startTag.exec(content)) !== null) {
    if (typeof opt.onMatch === 'function') {
      opt.onMatch(startMatch);
    }
    if (typeof opt.shouldAbort === 'function' && opt.shouldAbort(startMatch)) {
      continue;
    }
    // Take care of content length change:
    endTag.lastIndex = startTag.lastIndex;
    endMatch = endTag.exec(content);
    if (!endMatch) {
      throw error('Missing end tag for start tag: ' + startMatch[0]);
    }
    var toInject = opt.tagsToInject.slice();

    if (typeof opt.willInject === 'function') {
      opt.willInject(toInject);
    }

    // <everything before startMatch>:
    var newContents = content.slice(0, startMatch.index);

    if (opt.removeTags) {
      if (opt.empty) {
        // Take care of content length change:
        startTag.lastIndex -= startMatch[0].length;
      }
    } else {
      // <startMatch> + <endMatch>
      toInject.unshift(startMatch[0]);
      toInject.push(endMatch[0]);
    }
    var previousInnerContent = content.substring(startTag.lastIndex, endMatch.index);
    var indent = getLeadingWhitespace(previousInnerContent);
    // <new inner content>:
    newContents += toInject.join(indent);
    // <everything after endMatch>:
    newContents += content.slice(endTag.lastIndex);
    // Replace old content with new:
    content = newContents;
  }

  return content;
}
528884
function() {
    const self = this;
    const outBindPrep = this._prepOutbindings(
      this.single.insert,
      this.single.returning
    );
    const outBinding = outBindPrep.outBinding;
    const returning = outBindPrep.returning;
    const insertValues = outBindPrep.values;

    if (
      Array.isArray(insertValues) &&
      insertValues.length === 1 &&
      _.isEmpty(insertValues[0])
    ) {
      return this._addReturningToSqlAndConvert(
        'insert into ' +
          this.tableName +
          ' (' +
          this.formatter.wrap(this.single.returning) +
          ') values (default)',
        outBinding[0],
        this.tableName,
        returning
      );
    }

    if (
      _.isEmpty(this.single.insert) &&
      typeof this.single.insert !== 'function'
    ) {
      return '';
    }

    const insertData = this._prepInsert(insertValues);

    const sql = {};

    if (_.isString(insertData)) {
      return this._addReturningToSqlAndConvert(
        'insert into ' + this.tableName + ' ' + insertData,
        outBinding[0],
        this.tableName,
        returning
      );
    }

    if (insertData.values.length === 1) {
      return this._addReturningToSqlAndConvert(
        'insert into ' +
          this.tableName +
          ' (' +
          this.formatter.columnize(insertData.columns) +
          ') values (' +
          this.formatter.parameterize(insertData.values[0]) +
          ')',
        outBinding[0],
        this.tableName,
        returning
      );
    }

    const insertDefaultsOnly = insertData.columns.length === 0;
    sql.returning = returning;
    sql.sql =
      'begin ' +
      _.map(insertData.values, function(value, index) {
        const parameterizedValues = !insertDefaultsOnly
          ? self.formatter.parameterize(value, self.client.valueForUndefined)
          : '';
        let subSql = 'insert into ' + self.tableName;

        if (insertDefaultsOnly) {
          // No columns given so only the default value
          subSql +=
            ' (' +
            self.formatter.wrap(self.single.returning) +
            ') values (default)';
        } else {
          subSql +=
            ' (' +
            self.formatter.columnize(insertData.columns) +
            ') values (' +
            parameterizedValues +
            ')';
        }

        let returningClause = '';
        let intoClause = '';
        // ToDo review if this code is still needed or could be dropped
        // eslint-disable-next-line no-unused-vars
        let usingClause = '';
        let outClause = '';

        _.each(value, function(val) {
          if (!(val instanceof BlobHelper)) {
            usingClause += ' ?,';
          }
        });
        usingClause = usingClause.slice(0, -1);

        // Build returning and into clauses
        _.each(outBinding[index], function(ret) {
          const columnName = ret.columnName || ret;
          returningClause += self.formatter.wrap(columnName) + ',';
          intoClause += ' ?,';
          outClause += ' out ?,';

          // Add Helpers to bindings
          if (ret instanceof BlobHelper) {
            return self.formatter.bindings.push(ret);
          }
          self.formatter.bindings.push(new ReturningHelper(columnName));
        });

        // Strip last comma
        returningClause = returningClause.slice(0, -1);
        intoClause = intoClause.slice(0, -1);
        outClause = outClause.slice(0, -1);

        if (returningClause && intoClause) {
          subSql += ' returning ' + returningClause + ' into' + intoClause;
        }

        // Pre bind position because subSql is an execute immediate parameter
        // later position binding will only convert the ? params
        subSql = self.formatter.client.positionBindings(subSql);
        const parameterizedValuesWithoutDefaultAndBlob = parameterizedValues
          .replace('DEFAULT, ', '')
          .replace(', DEFAULT', '')
          .replace('EMPTY_BLOB(), ', '')
          .replace(', EMPTY_BLOB()', '');
        return (
          "execute immediate '" +
          subSql.replace(/'/g, "''") +
          (parameterizedValuesWithoutDefaultAndBlob || value
            ? "' using "
            : '') +
          parameterizedValuesWithoutDefaultAndBlob +
          (parameterizedValuesWithoutDefaultAndBlob && outClause ? ',' : '') +
          outClause +
          ';'
        );
      }).join(' ') +
      'end;';

    sql.outBinding = outBinding;
    if (returning[0] === '*') {
      // Generate select statement with special order by
      // to keep the order because 'in (..)' may change the order
      sql.returningSql = function() {
        return (
          'select * from ' +
          self.tableName +
          ' where ROWID in (' +
          this.outBinding
            .map(function(v, i) {
              return ':' + (i + 1);
            })
            .join(', ') +
          ')' +
          ' order by case ROWID ' +
          this.outBinding
            .map(function(v, i) {
              return 'when CHARTOROWID(:' + (i + 1) + ') then ' + i;
            })
            .join(' ') +
          ' end'
        );
      };
    }

    return sql;
  }
437347
def _SanitizeField(self, field):
    
    if self._FIELD_DELIMITER and isinstance(field, py2to3.STRING_TYPES):
      return field.replace(self._FIELD_DELIMITER, ' ')
    return field
382827
function inject() {
        if (!WIN || !needsInject) { return }
        needsInject = false;
        var style = Object.keys(byName)
          .map(function (k) { return byName[k]; })
          .concat(remainder).join('\n');
        /* istanbul ignore next */
        if (cssTextProp) { cssTextProp.cssText = style; }
        else { styleNode.innerHTML = style; }
      }
418150
function initField(target, property, desc) {
        let value = desc.initializer();

        hook(actionSet, action => {
            value = action.payload;
        })

        delete desc.initializer;
        delete desc.writable;

        desc.get = function() {
            return value;
        }
        desc.set = function() {
        }

        return desc;
    }
954708
@SuppressWarnings("unchecked")
    private static void injectInnerComponent(final Component<?> component, final Field field, final Object... keyParts) {

        final ParameterizedType innerComponentType = (ParameterizedType) field.getGenericType();
        final Class<?> componentType = (Class<?>) innerComponentType.getActualTypeArguments()[0];

        try {
            ClassUtility.setFieldValue(field, component, CBuilder.innerComponent((Class<Command>) componentType, keyParts).host(component));

        } catch (IllegalArgumentException | CoreException e) {
            LOGGER.error(COMPONENT_INJECTION_FAILURE, component.getClass(), e);
        }

    }
1148440
function(fields, oldValue) {
            fields = this.__resolveFields(fields);

            var prop, key, i, ii;

            this.__checkEmitEvent(true);

            if (_.isSimpleObject(oldValue)) {
                for (key in oldValue) {
                    this.__emitPropertyRemove(fields.concat(key), oldValue[key]);
                }
            }
            else if (_.isArray(oldValue)) {
                for (i = 0, ii = oldValue.length; i < ii; ++i) {
                    this.__emitPropertyRemove(fields.concat(i), oldValue[i]);
                }
            }

            prop = fields.join('.');

            this.__emitEvent('property.' + prop + '.clear', oldValue);
            this.__emitEvent('property.clear', prop, oldValue);

            return this;
        }
56178
function (i) {
                    if (i >= columns.length) {
                        insertIntoDB();
                        return;
                    }

                    var dbField = columns[i];
                    var field = dbField.Field;

                    //Check required fields
                    if (dbField.Null === 'NO' && 
                        dbField.Default === '' && 
                        dbField.Extra !== 'auto_increment' && 
                        dbField.Extra.search('on update')===-1) {

                        //Check if field not set
                        if (undefOrEmpty(req.body[field])) {
                            return sendError(res,"Field " + field + " is NOT NULL but not specified in this request");
                        } else {
                            //Check if the set values are roughly okay
                            value = checkIfSentvaluesAreSufficient(req,dbField);
                            console.log(value);
                            if(value !== false) {
                                //Value seems okay, go to the next field
                                insertJson[field] = value;
                                iterator(i + 1);
                            } else {
                                return sendError(res,'Value for field ' + field + ' is not sufficient. Expecting ' + dbField.Type + ' but got ' + typeof req.body[field] );
                            }
                        }
                    }  else {
                        //Check for not required fields
                        //Skip auto_incremented fields
                        if(dbField.Extra === 'auto_increment') {
                            iterator(i + 1);
                        } else {
                            //Check if the field was provided by the client
                            var defined = false;
                            if(dbField.Default == "FILE") {
                                if(req.files.hasOwnProperty(dbField.Field)) {
                                    defined = true;
                                }
                            } else {
                                if(typeof req.body[field] !== "undefined") {
                                    defined = true;
                                }
                            }

                            //If it was provided, check if the values are okay
                            if(defined) {
                                value = checkIfSentvaluesAreSufficient(req,dbField);
                                if(value !== false) {
                                    insertJson[field] = value;
                                    iterator(i + 1);
                                } else {
                                    if(dbField.Default == "FILE") {
                                        return sendError(res, 'Value for field ' + field + ' is not sufficient. Either the file is to large or an other error occured');
                                    } else {
                                        return sendError(res, 'Value for field ' + field + ' is not sufficient. Expecting ' + dbField.Type + ' but got ' + typeof req.body[field]);
                                    }
                                }
                            } else {
                                //If not, don't mind
                                iterator(i + 1);
                            }

                        }
                    }

                }
1370557
public void injectParams(JsonObject queryJson) {
        if (this.serverSideTimeout != null) {
            queryJson.put("timeout", this.serverSideTimeout);
        }

        if (this.clientContextId != null) {
            queryJson.put("client_context_id", this.clientContextId);
        }

        if (pretty) {
            queryJson.put("pretty", true);
        }

        if (deferred) {
            queryJson.put("mode", "async");
        }

        if (this.rawParams != null) {
            for (Map.Entry<String, Object> entry : rawParams.entrySet()) {
                queryJson.put(entry.getKey(), entry.getValue());
            }
        }
    }
1285518
function normalizeField(input) {
  assert(input.name, 'fields must have a name');

  var ret = clone(input);

  var cls = normalizeClass(input.class);
  if (cls) ret.class = cls;

  return ret;
}
594487
private static Field[] removeMetaFields(Field[] fields) {
		Field[] realFields = new Field[fields.length - 1];
		//We'll delete at least one, sometimes more than one field (because there's at least the r$type field).
		int i = 0;
		for (Field field : fields) {
			if (!field.getName().startsWith(Constants.PREFIX)) {
				realFields[i++] = field;
			}
		}
		if (i < realFields.length) {
			realFields = Utils.arrayCopyOf(realFields, i);
		}
		if (GlobalConfiguration.assertsMode) {
			Utils.assertTrue(i == realFields.length, "Bug in removeMetaFields, created array of wrong length");
		}
		return realFields;
	}
307574
private static Object injectAndPostConstruct(Object injectionProvider, Class Klass, List injectedBeanStorage)
    {
        Object instance = null;
        if (injectionProvider != null)
        {
            try
            {

                Object managedObject = _FactoryFinderProviderFactory.INJECTION_PROVIDER_INJECT_CLASS_METHOD.invoke(injectionProvider, Klass);

                instance = _FactoryFinderProviderFactory.MANAGED_OBJECT_GET_OBJECT_METHOD.invoke(managedObject, null);

                if (instance != null) {

                    Object creationMetaData = _FactoryFinderProviderFactory.MANAGED_OBJECT_GET_CONTEXT_DATA_METHOD.invoke
                                    (managedObject, CreationalContext.class);

                    addBeanEntry(instance, creationMetaData, injectedBeanStorage);

                    _FactoryFinderProviderFactory.INJECTION_PROVIDER_POST_CONSTRUCT_METHOD.invoke(
                                                                                                  injectionProvider, instance, creationMetaData);
                }
            } catch (Exception ex)
            {
                throw new FacesException(ex);
            }
        }
        return instance;
    }
54757
@SuppressWarnings("unchecked")
    private static void injectComponent(final FacadeReady<?> component, final Field field, final Object... keyParts) {

        try {
            if (Command.class.isAssignableFrom(field.getType())) {
                ClassUtility.setFieldValue(field, component, component.localFacade().globalFacade().commandFacade().retrieve((Class<Command>) field.getType(), keyParts));
            } else if (Service.class.isAssignableFrom(field.getType())) {
                ClassUtility.setFieldValue(field, component, component.localFacade().globalFacade().serviceFacade().retrieve((Class<Service>) field.getType(), keyParts));
            } else if (Model.class.isAssignableFrom(field.getType())) {
                ClassUtility.setFieldValue(field, component, component.localFacade().globalFacade().uiFacade().retrieve((Class<Model>) field.getType(), keyParts));
            }
        } catch (IllegalArgumentException | CoreException e) {
            LOGGER.error(COMPONENT_INJECTION_FAILURE, component.getClass(), e);
        }

    }
160781
function(model, id, settings, obj, options, cb) {
      var fieldName, i, len, ref;
      if (settings == null) {
        settings = {};
      }
      if (obj == null) {
        obj = {};
      }
      if (options == null) {
        options = {};
      }
      if (cb == null) {
        cb = function() {};
      }
      Hoek.assert(model, i18n.assertModuleRequired);
      Hoek.assert(id, i18n.assertIdRequired);
      ref = settings.exclude || [];
      for (i = 0, len = ref.length; i < len; i++) {
        fieldName = ref[i];
        delete obj[fieldName];
      }
      if (_.isFunction(options)) {
        cb = options;
        options = {};
      }
      return model.findByIdAndUpdate({
        _id: asObjectId(id)
      }, {
        $set: obj
      }, {
        "new": true
      }, cb);
    }
27400
private void initAnnotatedFields() {
        final Set<Field> hiddenFields = Reflections.getHiddenFields(beanClass);
        inject(hiddenFields);

        final Set<Field> inheritedFields = Reflections.getInheritedFields(beanClass);
        inject(inheritedFields);

        final Set<Field> ownFields = Reflections.getOwnFields(beanClass);
        inject(ownFields);
    }
1062755
private IDLProxyObject doSetFieldValue(String fullField, String field, Object value, Object object,
            boolean useCache, Map<String, ReflectInfo> cachedFields) {
        Field f;
        // check cache
        if (useCache) {
            ReflectInfo info = cachedFields.get(fullField);
            if (info != null) {
                setField(value, info.target, info.field);
                return this;
            }
        }

        int index = field.indexOf('.');
        if (index != -1) {
            String parent = field.substring(0, index);
            String sub = field.substring(index + 1);

            try {
                f = FieldUtils.findField(object.getClass(), parent);
                if (f == null) {
                    throw new RuntimeException(
                            "No field '" + parent + "' found at class " + object.getClass().getName());
                }
                Class<?> type = f.getType();
                f.setAccessible(true);
                Object o = f.get(object);
                if (o == null) {
                    boolean memberClass = type.isMemberClass();
                    if (memberClass && Modifier.isStatic(type.getModifiers())) {
                        Constructor<?> constructor = type.getConstructor(new Class[0]);
                        constructor.setAccessible(true);
                        o = constructor.newInstance(new Object[0]);
                    } else if (memberClass) {
                        Constructor<?> constructor = type.getConstructor(new Class[] { object.getClass() });
                        constructor.setAccessible(true);
                        o = constructor.newInstance(new Object[] { object });
                    } else {
                        o = type.newInstance();
                    }
                    f.set(object, o);
                }
                return put(fullField, sub, value, o);
            } catch (Exception e) {
                throw new RuntimeException(e.getMessage(), e);
            }
        }

        f = FieldUtils.findField(object.getClass(), field);
        if (f == null) {
            throw new RuntimeException("No field '" + field + "' found at class " + object.getClass().getName());
        }
        if (useCache && !cachedFields.containsKey(fullField)) {
            cachedFields.put(fullField, new ReflectInfo(f, object));
        }
        setField(value, object, f);

        return this;
    }