Validate injected parameters and options
424738
public void validate() {
        for (String in : getInputFiles()) {
            if (!new File(in).exists())
                throwValidationException("ERROR: input file \"" + in + "\" does not exist.", false);
            validateInfo(in);
        }
    }
1086598
function validateParamsPresent(expectedKeys, params) {
  params = params || {};
  var paramKeys = _.keys(params);
  return _.first(_.difference(expectedKeys, _.intersection(paramKeys, expectedKeys)));
}
1021429
function validateOptions(options) {
  if (!options) {
    return;
  }

  utils.each(['varControls', 'tagControls', 'cmtControls'], function (key) {
    if (!options.hasOwnProperty(key)) {
      return;
    }
    if (!utils.isArray(options[key]) || options[key].length !== 2) {
      throw new Error('Option "' + key + '" must be an array containing 2 different control strings.');
    }
    if (options[key][0] === options[key][1]) {
      throw new Error('Option "' + key + '" open and close controls must not be the same.');
    }
    utils.each(options[key], function (a, i) {
      if (a.length < 2) {
        throw new Error('Option "' + key + '" ' + ((i) ? 'open ' : 'close ') + 'control must be at least 2 characters. Saw "' + a + '" instead.');
      }
    });
  });

  if (options.hasOwnProperty('cache')) {
    if (options.cache && options.cache !== 'memory') {
      if (!options.cache.get || !options.cache.set) {
        throw new Error('Invalid cache option ' + JSON.stringify(options.cache) + ' found. Expected "memory" or { get: function (key) { ... }, set: function (key, value) { ... } }.');
      }
    }
  }
  if (options.hasOwnProperty('loader')) {
    if (options.loader) {
      if (!options.loader.load || !options.loader.resolve) {
        throw new Error('Invalid loader option ' + JSON.stringify(options.loader) + ' found. Expected { load: function (pathname, cb) { ... }, resolve: function (to, from) { ... } }.');
      }
    }
  }

}
361388
private static void validateParams(List<Object> params, Class<?> classz) {

        // skip validation if not uimafit
        if (!JCasAnnotator_ImplBase.class.isAssignableFrom(classz)
                && !JCasCollectionReader_ImplBase.class.isAssignableFrom(//
                        classz)) {
            LOG.warn(
                    "    +- Could not validate parameters in {}. You might want to check it manually.",
                    classz.getName());
            return;
        }

        for (int i = 0; i < params.size(); i = i + 2) {
            String paramName = (String) params.get(i);
            try {

                // add fields from superclass as well
                Set<Field> fields = newHashSet(classz.getDeclaredFields());
                fields.addAll(newHashSet(classz.getSuperclass()
                        .getDeclaredFields()));

                List<String> paramNames = new ArrayList<String>();
                for (Field f : fields) {
                    if (f.isAnnotationPresent(ConfigurationParameter.class)) {
                        ConfigurationParameter confParam = f
                                .getAnnotation(ConfigurationParameter.class);
                        paramNames.add(confParam.name());
                    }
                }

                if (!paramNames.contains(paramName)) {
                    LOG.warn(
                            "    +-XXXXXXXXX Could not find parameter '{}' in {}. You should check it.",
                            paramName, classz.getName());
                    LOG.warn("    +-XXXXXXXXX Available parameters are:\n",
                            join(paramNames, "\n"));
                }
            } catch (SecurityException e) {
                LOG.error(
                        "could not validate params for "
                                + classz.getSimpleName(), e);
            }
        }
    }
27936
async function validateArguments(args, operation) {
    let error = new Error();
    let body = undefined;

    error.name = 'ArgumentError';
    if (!operation) {
        let verbs = ["add", "clone", "delete", "export", "package", "get", "import", "list", "publish", "query", "set", "suggest", "train", "update"];
        if (verbs.indexOf(args._[0]) < 0)
            error.message = `'${args._[0]}' is not a valid action`;
        else if (args._.length >= 2)
            error.message = `'${args._[1]}' is not a valid resource`;
        else
            error.message = `missing resource\n`;
        throw error;
    }

    switch (operation.target[0]){
        case "userazureaccounts":
        case "appazureaccounts":
            switch (operation.methodAlias) {
                case "list":
                    if (args.hasOwnProperty("armToken")) {
                        args.customHeaders["Authorization"] = `Bearer ${args.armToken}`;
                    }
                    break;
                }
                break;
                case "appazureaccount":
                    switch (operation.methodAlias) {
                        case "add":
                        case "delete":
                            if (args.hasOwnProperty("armToken")) {
                                args.customHeaders["Authorization"] = `Bearer ${args.armToken}`;
                            }
                            break;
                        }
                        break;
    }

    const entitySpecified = typeof args.in === 'string';
    const entityRequired = !!operation.entityName;

    if (entityRequired) {
        if (entitySpecified) {
            body = await getFileInput(args);
        }
        else {
            // make up a request body from command line args
            switch (operation.target[0]) {
                case "version":
                    switch (operation.methodAlias) {
                        case "publish":
                            if (args.versionId) {
                                body = {
                                    versionId: `${args.versionId}`,
                                    isStaging: args.staging === 'true'
                                };
                            }
                            break;
                        case "rename":
                        case "update":
                        case "clone":
                            if (args.newVersionId) {
                                body = {
                                    version: `${args.newVersionId}`
                                };
                            }
                            break;
                    }
                    break;

                case "settings":
                    switch (operation.methodAlias) {
                        case "update":
                            if (args.hasOwnProperty("public")) {
                                body = {
                                    isPublic: args.public === 'true'
                                };
                            }
                            break;
                    }
                    break;
                case "versionsettings":
                    switch (operation.methodAlias) {
                        case "update":
                            if (args.hasOwnProperty("useAllTrainingData")) {
                                body = [{
                                    name: "UseAllTrainingData",
                                    value: args.useAllTrainingData === 'true' ? 'true' : 'false'
                                }];
                            }
                            break;
                    }
                    break;
                case "appazureaccount":
                    if (args.azureSubscriptionId && args.resourceGroup && args.accountName) {
                        body = {
                            azureSubscriptionId: `${args.azureSubscriptionId}`,
                            resourceGroup: `${args.resourceGroup}`,
                            accountName: `${args.accountName}`
                        };
                    }
                    break;

                default:
                    error.message = `The --in requires an input of type: ${operation.entityType}`;
                    throw error;
            }
        }
    }
    return body;
    // Note that the ServiceBase will validate params that may be required.
}
461197
function validateOption (options, name, values) {
  if (options[name] !== undefined && !contains(values, options[name])) {
    const index = findIndex(values, options[name])
    if (index !== -1) {
      // right value, wrong casing
      // TODO: lower case values are deprecated since v3, remove this warning some day.
      console.warn('Warning: Wrong casing for configuration option "' + name + '", should be "' + values[index] + '" instead of "' + options[name] + '".')

      options[name] = values[index] // change the option to the right casing
    } else {
      // unknown value
      console.warn('Warning: Unknown value "' + options[name] + '" for configuration option "' + name + '". Available options: ' + values.map(JSON.stringify).join(', ') + '.')
    }
  }
}
307350
function validate(cmd, args, info) {
  AbstractCommand.prototype.validate.apply(this, arguments);
  var offset = 2
    , arg
    , expires;

  // need string args (except for key, value)
  args.forEach(function(a, i, arr) {
    if(i > 1) {
      arr[i] = '' + a;
    }
  })

  if(args.length > 7) {
    throw new CommandArgLength(cmd);
  }else if(args.length > 2) {
    arg = args[offset];
    while(arg !== undefined) {
      arg = arg.toLowerCase();
      args[offset] = arg;
      if(arg !== Constants.EX
        && arg !== Constants.PX
        && arg !== Constants.NX
        && arg !== Constants.XX) {
        throw CommandSyntax;
      }
      if(arg === Constants.EX || arg === Constants.PX) {
        expires = parseInt('' + args[offset + 1]);
        if(isNaN(expires)) {
          throw IntegerRange;
        }
        args[++offset] = expires;
      }
      arg = args[++offset];
    }
  }
}
121366
function allowOptionalParams(params, callback) {
    if (!callback) {
        callback = params;
        params = { };
    }
    return {
        params: params,
        callback: callback,
    };
}
1006975
function validateOptions(options) {
  const notSupported = _.reject(_.keys(options), (key) => (
    OPTIONS.has(key)
  ));

  if (notSupported.length > 0) {
    console.warn(`[${PLUGIN_NAME}] Options ${notSupported} are not supported, use following options: ${Array.from(OPTIONS)}`);
  }
}
1336865
def _validate_prepostcmd_hook(cls, func: Callable, data_type: Type) -> None:
        """"""
        signature = inspect.signature(func)
        # validate that the callable has the right number of parameters
        cls._validate_callable_param_count(func, 1)
        # validate the parameter has the right annotation
        paramname = list(signature.parameters.keys())[0]
        param = signature.parameters[paramname]
        if param.annotation != data_type:
            raise TypeError('argument 1 of {} has incompatible type {}, expected {}'.format(
                func.__name__,
                param.annotation,
                data_type,
            ))
        # validate the return value has the right annotation
        if signature.return_annotation == signature.empty:
            raise TypeError('{} does not have a declared return type, expected {}'.format(
                func.__name__,
                data_type,
            ))
        if signature.return_annotation != data_type:
            raise TypeError('{} has incompatible return type {}, expected {}'.format(
                func.__name__,
                signature.return_annotation,
                data_type,
            ))
1244490
private void validateParameterProviders() {
    Set<String> parameterNames = new HashSet<>();
    for (ParameterProvider provider : this.parameterProviders) {
      Set<String> applicationIdsOfThisProvider = new HashSet<>();
      for (Parameter<?> parameter : provider.getParameters()) {
        if (StringUtils.isNotEmpty(parameter.getApplicationId())) {
          applicationIdsOfThisProvider.add(parameter.getApplicationId());
        }
        if (parameterNames.contains(parameter.getName())) {
          log.warn("Parameter name is not unique: {} (application: {})", parameter.getName(), parameter.getApplicationId());
        }
        else {
          parameterNames.add(parameter.getName());
        }
      }
      if (applicationIdsOfThisProvider.size() > 1) { //NOPMD
        log.warn("Parameter provider {} defines parameters with multiple application Ids: {}", provider,
            applicationIdsOfThisProvider.toArray(new String[applicationIdsOfThisProvider.size()]));
      }
    }
  }
1310009
function validateRuleOptions(id, options, source) {
		var validateRule = validators.rules[id],
			message,
			severity,
			localOptions,
			schema = getRuleOptionsSchema(id),
			validSeverity = true;

		/* ORION no CQ for is-my-json-valid library
		 if (!validateRule && schema) {
			validateRule = schemaValidator(schema, {
				verbose: true
			});
			validators.rules[id] = validateRule;
		}*/

		// if it's not an array, it should be just a severity
		if (Array.isArray(options)) {
			localOptions = options.concat(); // clone
			severity = localOptions.shift();
		} else {
			severity = options;
			localOptions = [];
		}

		validSeverity = (
			severity === 0 || severity === 1 || severity === 2 ||
			(typeof severity === "string" && /^(?:off|warn|error)$/i.test(severity))
		);

		if (validateRule) {
			validateRule(localOptions);
		}

		if ((validateRule && validateRule.errors) || !validSeverity) {
			message = [
				source, ":\n",
				"\tConfiguration for rule \"", id, "\" is invalid:\n"
			];

			if (!validSeverity) {
				message.push(
					"\tSeverity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '",
					util.inspect(severity).replace(/'/g, "\"").replace(/\n/g, ""),
					"').\n"
				);
			}

			if (validateRule && validateRule.errors) {
				validateRule.errors.forEach(function(error) {
					message.push(
						"\tValue \"", error.value, "\" ", error.message, ".\n"
					);
				});
			}

			throw new Error(message.join(""));
		}
	}
668507
private function validateScriptParams()
    {
        $this->script_params = array_intersect_key(
            $this->script_params,
            array_fill_keys(self::$valid_script_params, null)
        );
    }
1115304
function validateBodyParameters (params, operationId) {
  var bodyParams = params.filter(function (param) { return param.in === "body"; });
  var formParams = params.filter(function (param) { return param.in === "formData"; });

  // There can only be one "body" parameter
  if (bodyParams.length > 1) {
    throw ono.syntax(
      "Validation failed. %s has %d body parameters. Only one is allowed.",
      operationId, bodyParams.length
    );
  }
  else if (bodyParams.length > 0 && formParams.length > 0) {
    // "body" params and "formData" params are mutually exclusive
    throw ono.syntax(
      "Validation failed. %s has body parameters and formData parameters. Only one or the other is allowed.",
      operationId
    );
  }
}
338177
function validated(invalid){
            if (invalid) { return callback(invalid) }
            if(options.coerce){crudUtils.coerceData(options,coerced())}
            else{coerced(null,options.data)}
        }
118910
def validate_path_parameters(target_path, api_path, path_parameters, context):
    
    base_path = context.get('basePath', '')
    full_api_path = re.sub(NORMALIZE_SLASH_REGEX, '/', base_path + api_path)
    parameter_values = get_path_parameter_values(
        target_path, full_api_path, path_parameters, context,
    )
    validate_parameters(parameter_values, path_parameters, context=context)
690597
def validate_experimental(context, param, value):
    """"""
    if value is None:
        return
    config = ExperimentConfiguration(value)
    config.validate()
    return config