<commit_before>const { findOneByName } = require('../../common')


function validateOption(name, value, config) {
  if (config.required && typeof value === 'undefined') {
    throw new Error(`Option "${name}" is required`)
  }
}

function validateCommand(command, commandConfig, options, optionConfigs) {
  Object.keys(options).forEach((option) => {
    let optionConfig = findOneByName(optionConfigs, option)
    let optionValue = options[option]

    if (!optionConfig && commandConfig.strict) {
      throw new Error(`Unknown option ${option}`)
    }

    validateOption(option, optionValue, optionConfig)
  })
}


module.exports = validateCommand<commit_msg>Fix validation failing for unknown options<commit_after>const { findOneByName } = require('../../common')


function validateOption(name, value, config) {
  if (config.required && typeof value === 'undefined') {
    throw new Error(`Option "${name}" is required`)
  }
}

function validateCommand(command, commandConfig, options, optionConfigs) {
  Object.keys(options).forEach((option) => {
    let optionConfig = findOneByName(optionConfigs, option)
    let optionValue = options[option]

    if (!optionConfig) {
      if (commandConfig.strict) {
        throw new Error(`Unknown option ${option}`)
      }

      return
    }

    validateOption(option, optionValue, optionConfig)
  })
}


module.exports = validateCommand
{'fraction_non_alphanumeric': 0.13121845710165825, 'fraction_numerical': 0.0, 'mean_word_length': 4.17910447761194, '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': '6070494', 'n_tokens_mistral': 382, 'n_tokens_neox': 376, 'n_words': 94}