<commit_before>/**
 * @module environment
 * @description
 * Update the given environment
 */
const properties = require('./properties');
const keywords = require('./keywords');
const validators = require('../validators');

const contains = require('../validators/contains');
const constant = require('../validators/const');
const propertyNames = require('../validators/propertyNames');

const environmentConfig = {
  // TODO remove side effects
  // TODO make draft-06 default
  'draft-06': () => {
    Object.assign(properties, {
      exclusiveMinimum(schema) {
        return `%s <= ${schema.exclusiveMinimum}`;
      },
      minimum(schema) {
        return `%s < ${schema.minimum}`;
      },
      exclusiveMaximum(schema) {
        return `%s >= ${schema.exclusiveMaximum}`;
      },
      maximum(schema) {
        return `%s > ${schema.maximum}`;
      },
    });

    ['exclusiveMaximum', 'exclusiveMininum'].forEach((key) => {
      const index = keywords.indexOf(key);
      if (index === -1) {
        return;
      }

      keywords.splice(index, 1);
    });

    if (validators.list.indexOf(contains) === -1) {
      validators.list.push(
        contains,
        constant,
        propertyNames
      );
    }

    Object.assign(validators.name, {
      contains,
      constant,
      propertyNames
    });
  },
};

module.exports = function environment(version) {
  if (!version || !environmentConfig[version]) {
    return;
  }

  const patchEnvironment = environmentConfig[version];
  patchEnvironment();<commit_msg>feat(validator): Add json-pointer format #44<commit_after>/**
 * @module environment
 * @description
 * Update the given environment
 */
const properties = require('./properties');
const keywords = require('./keywords');
const validators = require('../validators');
const formats = require('./formats');

const contains = require('../validators/contains');
const constant = require('../validators/const');
const propertyNames = require('../validators/propertyNames');

const environmentConfig = {
  // TODO remove side effects
  // TODO make draft-06 default
  'draft-06': () => {
    Object.assign(properties, {
      exclusiveMinimum(schema) {
        return `%s <= ${schema.exclusiveMinimum}`;
      },
      minimum(schema) {
        return `%s < ${schema.minimum}`;
      },
      exclusiveMaximum(schema) {
        return `%s >= ${schema.exclusiveMaximum}`;
      },
      maximum(schema) {
        return `%s > ${schema.maximum}`;
      },
    });

    ['exclusiveMaximum', 'exclusiveMininum'].forEach((key) => {
      const index = keywords.indexOf(key);
      if (index === -1) {
        return;
      }

      keywords.splice(index, 1);
    });

    if (validators.list.indexOf(contains) === -1) {
      validators.list.push(
        contains,
        constant,
        propertyNames
      );
    }

    Object.assign(validators.name, {
      contains,
      constant,
      propertyNames
    });

    Object.assign(formats, {
      'json-pointer': '!/^$|^\\/(?:~(?=[01])|[^~])*$/.test(%s)' // add empty valid string
    });
  },
};

module.exports = function environment(version) {
  if (!version || !environmentConfig[version]) {
    return;
  }

  const patchEnvironment = environmentConfig[version];
  patchEnvironment();
{'fraction_non_alphanumeric': 0.1655973113351665, 'fraction_numerical': 0.005499541704857928, 'mean_word_length': 2.758897818599311, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '7115887', 'n_tokens_mistral': 951, 'n_tokens_neox': 926, 'n_words': 187}