<commit_before>var validate = require('validate.js');

validate.validators.features = function(value/*, options, key, attributes */) {
  if (typeof (value) === 'undefined' || value === null)
      return value;
  if (!validate.isArray(value))
      return 'needs to be a list of features';
  for (var i = value.length - 1; i >= 0; i--) {
    if (validate(value[i], feature))
        return 'should have group and value keys';
  }
};

validate.validators.isArray = function(value/*, options, key, attributes */) {
  if (!validate.isArray(value))
      return 'needs to be an array';
};

var feature = {
  group: {presence: true},
  value: {presence: true},
};

var engagement = {
  'label': {presence: true},
  'boost': {
    presence: false,
    numericality: true,
  },
  'features': {
    features: true,
  },
};

var impression = {
  'foreign_ids': {
    presence: true,
    isArray: true,
  },
  'boost': {
    presence: false,
    numericality: true,
  },
  'features': {
    features: true,
  },
};

module.exports = {
  engagementSpec: engagement,
  impressionSpec: impression,
};<commit_msg>disable feature spec validation for impressions<commit_after>var validate = require('validate.js');

validate.validators.features = function(value/*, options, key, attributes */) {
  if (typeof (value) === 'undefined' || value === null)
      return value;
  if (!validate.isArray(value))
      return 'needs to be a list of features';
  for (var i = value.length - 1; i >= 0; i--) {
    if (validate(value[i], feature))
        return 'should have group and value keys';
  }
};

validate.validators.isArray = function(value/*, options, key, attributes */) {
  if (!validate.isArray(value))
      return 'needs to be an array';
};

validate.validators.isObject = function(value/*, options, key, attributes */) {
  if (!validate.isArray(value))
      return 'needs to be an array';
};

var feature = {
  group: {presence: true},
  value: {presence: true},
};

var engagement = {
  'label': {presence: true},
  'boost': {
    presence: false,
    numericality: true,
  },
  'features': {
    features: true,
  },
};

var impression = {
  'foreign_ids': {
    presence: true,
    isArray: true,
  },
  'boost': {
    presence: false,
    numericality: true,
  },
  // 'features': {
  //   isObject: true,
  // },
};

module.exports = {
  engagementSpec: engagement,
  impressionSpec: impression,
};
{'fraction_non_alphanumeric': 0.16290726817042606, 'fraction_numerical': 0.001670843776106934, 'mean_word_length': 3.2314487632508833, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '7077179', 'n_tokens_mistral': 770, 'n_tokens_neox': 780, 'n_words': 214}