<commit_before>/**
 * Handles validation on a model
 *
 * Used Anchor for validating
 * https://github.com/balderdashy/anchor
 */

var Validator = module.exports = function() {
  this.validations = {};
};


/**
 * Builds a Validation Object from an attributes
 * object in a model.
 *
 * Loops through an attributes object to build a validation object
 * containing attribute name as key and a series of validations that
 * are run on each model. Skips over type and defaultsTo as they are
 * schema properties.
 *
 * Example:
 *
 * attributes: {
 *   name: {
 *     type: 'string',
 *     length: { min: 2, max: 5 }
 *   }
 *   email: {
 *     type: 'string',
 *     required: true
 *   }
 * }
 *
 * Returns: {
 *   name: { length: { min:2, max: 5 }},
 *   email: { required: true }
 * }
 *
 * @return {Object}
 */

Validator.prototype.build = function(attrs) {
  var self = this;

  Object.keys(attrs).forEach(function(attr) {

    // Ignore Key/Value attributes
    // these are schema only attributes
    if(typeof attrs[attr] === 'string') return;

    Object.keys(attrs[attr]).forEach(function(key) {

      // Check if type or defaultsTo
      // these are schema only attributes
      if(['type', 'defaultsTo'].indexOf(key) > -1) return;

      // Pass everything else to the validator for now?
      // Need to look more into Anchor internals to see how
      // it works exactly
      self.validations[attr] = self.validations[attr] || {};
      self.validations[attr][key] = attrs[attr][key];
    });

  });
};<commit_msg>add additional schema level attributes to validation exclusions<commit_after>/**
 * Handles validation on a model
 *
 * Used Anchor for validating
 * https://github.com/balderdashy/anchor
 */

var Validator = module.exports = function() {
  this.validations = {};
};


/**
 * Builds a Validation Object from an attributes
 * object in a model.
 *
 * Loops through an attributes object to build a validation object
 * containing attribute name as key and a series of validations that
 * are run on each model. Skips over type and defaultsTo as they are
 * schema properties.
 *
 * Example:
 *
 * attributes: {
 *   name: {
 *     type: 'string',
 *     length: { min: 2, max: 5 }
 *   }
 *   email: {
 *     type: 'string',
 *     required: true
 *   }
 * }
 *
 * Returns: {
 *   name: { length: { min:2, max: 5 }},
 *   email: { required: true }
 * }
 *
 * @return {Object}
 */

Validator.prototype.build = function(attrs) {
  var self = this;

  Object.keys(attrs).forEach(function(attr) {

    // Ignore Key/Value attributes
    // these are schema only attributes
    if(typeof attrs[attr] === 'string') return;

    Object.keys(attrs[attr]).forEach(function(key) {

      // Check to ensure it's not a schema only attribute
      if(['type', 'defaultsTo', 'primaryKey', 'autoIncrement', 'unique'].indexOf(key) > -1) return;

      // Pass everything else to the validator for now?
      // Need to look more into Anchor internals to see how
      // it works exactly
      self.validations[attr] = self.validations[attr] || {};
      self.validations[attr][key] = attrs[attr][key];
    });

  });
};
{'fraction_non_alphanumeric': 0.13584183673469388, 'fraction_numerical': 0.0031887755102040817, 'mean_word_length': 2.8302808302808304, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4102480', 'n_tokens_mistral': 958, 'n_tokens_neox': 938, 'n_words': 303}