<commit_before>'use strict';

const requiredTest = name => ({
  test ({ [name]: value }) {
    return value != null;
  },
  message: 'must be defined',
});

const forbiddenTest = name => ({
  test ({ [name]: value }) {
    return value == null;
  },
  message: 'must not be defined',
});

module.exports = {
  requiredTest,
  forbiddenTest,
};<commit_msg>Add unknownTest<commit_after>'use strict';

const { isEqual } = require('lodash');

const { get } = require('../../utilities');

const requiredTest = name => ({
  test (value) {
    return get(value, name.split('.')) != null;
  },
  message: 'must be defined',
});

const forbiddenTest = name => ({
  test (value) {
    return get(value, name.split('.')) == null;
  },
  message: 'must not be defined',
});

const unknownTest = (name, attributes) => ({
  test (value) {
    const val = get(value, name.split('.'));
    const keys = Object.keys(val);

    return isEqual(keys, attributes);
  },
  message () {
    const attrNames = attributes
      .map(attr => `'${attr}'`)
      .join(', ');
    return `'${name}' must only contain ${attrNames}`;
  },
});

module.exports = {
  requiredTest,
  forbiddenTest,
  unknownTest,
};
{'fraction_non_alphanumeric': 0.19373942470389172, 'fraction_numerical': 0.0, 'mean_word_length': 3.3018181818181818, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '7645872', 'n_tokens_mistral': 387, 'n_tokens_neox': 385, 'n_words': 101}