Helpers 
Validate record
358882
function validateRecord (table, record) {
  invariant(
    _.isString(table),
    'Must provide a table'
  )

  invariant(
    /^[a-z0-9_]{3,255}$/.test(table),
    'Table must be between 3 and 255 characters and must ' +
    'consist only of lower case letters, numbers, and _'
  )

  invariant(
    _.isObject(record),
    'Must provide a record'
  )
}
397821
function validate(args, required) {
    var result = {
      error: false,
      message: 'No errors'
    }

    // ensure required properties were passed in the arguments hash
    if (required) {
      var keys = _.keys(args);
      required.forEach(function(field) {
        if(!_.contains(keys, field)) {
          result.error = true;
          result.message = 'The following values must be passed: ' + required.join(', ');
        }
      })
    }

    return result;

  }
1341419
def associated_records_to_validate_or_save(association, new_record, autosave)
        if new_record
          association && association.target
        elsif autosave
          association.target.find_all { |record| record.changed_for_autosave? }
        else
          association.target.find_all { |record| record.new_record? }
        end
      end
726640
def validate(self, model, checks=[]):
        """"""
        records = self.data.to_dict("records")
        self.evaluate_report(
            validate(records, headers=list(records[0]),
                     preset='table', schema=self.schema,
                     order_fields=True, custom_checks=checks))
964236
function(model, attrs, validatedAttrs) {
      var error,
          invalidAttrs = {},
          isValid = true,
          computed = _.clone(attrs);

      _.each(validatedAttrs, function(val, attr) {
        error = validateAttrWithOpenArray(model, attr, val, computed);
        if (error) {
          invalidAttrs[attr] = error;
          isValid = false;
        }
      });

      return {
        invalidAttrs: invalidAttrs,
        isValid: isValid
      };
    }
1019194
def do_before_validation
      prim_slug, i = slug, 0
      prim_slug, i = $1, $2.to_i if slug =~ /^(.*)_([0-9]+)$/

      return unless prim_slug.present?

      attempts = 0
      conditions = new_record? ? ['slug = ?',slug] : ['slug = ? AND id != ?',slug,id]
      conditions[1] = "#{prim_slug}_#{i+=1}" while Page.where(conditions).first && (attempts += 1) < 20
      write_attribute(:slug,conditions[1])
    end
274625
private function validate_helper_input( $helper ) {
		if ( ! is_array( $helper ) || empty( $helper ) ) {
			return false;
		}

		if ( !  isset( $helper[ 'name' ] ) || ! isset( $helper[ 'class' ]  ) ) {
			return false;
		}

		//if not set, set callback name to "helper"
		if ( ! isset( $helper[ 'callback' ] ) ) {
			$helper[ 'callback' ] = 'helper';
		}

		return $helper;

	}
936942
function() {
    // Check for unknown attributes
    var key, unknownAttrs = []
    for (key in obj) {
      if (!self.validators.hasOwnProperty(key))
        unknownAttrs.push(key)
    }
    if (unknownAttrs.length)
      self._merge(validationErrors, 'unknown attributes [' + unknownAttrs.join(', ') + ']', prefix)
      //validationErrors[prefix || '.'] = 'unknown attributes [' + unknownAttrs.join(', ') + ']'

    // Run the `after` hook only if there is no validation error.
    if (isValid && self.after) {
      try {
        self.after.call(obj)
      } catch (err) {
        if(!_handleError(err)) return done(err)
      }
    }
    done(null, validationErrors)
  }
920520
def validate_collection_association(reflection)
        if association = association_instance_get(reflection.name)
          if records = associated_records_to_validate_or_save(association, new_record?, reflection.options[:autosave])
            records.each_with_index { |record, index| association_valid?(reflection, record, index) }
          end
        end
      end
1239508
def assert_valid(key, value)
      validators[key].each do |validator|
        validator.call(key, value)
      end
    end
654537
static function validate($schema, $value, $helper = NULL) {
    foreach (self::parseConstraints($schema) as $c) {  // The constraints are in a numeric array as the order matters.
      $constraint = key($c);
      $params     = $c[$constraint];

      if (self::isBlank($value) && ! preg_match('/require|notblank/i', $constraint)) continue; // Only *require* validators should check blank values.

      $value = self::constrain($value, $constraint, self::parseParams($params, $schema), $helper);
    }

    return $value;
  }
146648
def associated_records_to_validate_or_save(association,
                                               new_record,
                                               autosave)
      if new_record || autosave
        association && association.target
      else
        association.target.find_all(&:new_record?)
      end
    end
156385
function validate(key) {
        var type = getType(key);
        if (type === "array") {
            for (var i = 0; i < key.length; i++) {
                validate(key[i]);
            }
        }
        else if (!types[type] || (type !== "string" && isNaN(key))) {
            throw idbModules.util.createDOMException("DataError", "Not a valid key");
        }
    }
1256133
function validate(options) {
    const schema = joi.object().keys({
        actionName: joi.string().required(),
        authKey: joi.string().required(),
        modelName: joi.string().required(),
        acl: joi.object(),
        aclContextName: joi.string().required()
    });
    const errorMsg = 'Invalid rule options: ';
    const aclContext = options.acl[options.aclContextName];
    joi.assert(options, schema, errorMsg);
    joi.assert(aclContext, joi.func().required(), errorMsg);
    return true;
}
717829
function validate( options ) {
		var validator,
			keys,
			key,
			err;

		if ( !isObject( options ) ) {
			return new TypeError( 'Stream()::invalid input argument. Options must be an object.' );
		}
		keys = Object.keys( options );
		for ( var i = 0; i < keys.length; i++ ) {
			key = keys[ i ];
			validator = validators[ key ];
			err = validator( options[key] );
			if ( err ) {
				return err;
			}
		}
	}
1334254
function validateField(field, cb) {
        if (_.isArray(field.validation)) {
            async.each(field.validation, performValidation(field), function(err) {
                cb(err);
            });
        } else {
            cb();
        }
    }
117483
function validator(value, next) {
    validationErrors = [];
    var isValid = true;

    validatorsArray.forEach(function(validator) {
      validator.validator.call(this, value, function(valid) {
        if (!valid) {
          // Append message
          validationErrors.push(validator.message);

          isValid = false;
        }
      });
    }.bind(this));
    return next(isValid);
  }