Validate the API params as specified in the config file.
543511
def _validate_api_params(params):
    '''
    
    '''
    # page_id and API key are mandatory and they must be string/unicode
    return (isinstance(params['api_page_id'], (six.string_types, six.text_type)) and
            isinstance(params['api_key'], (six.string_types, six.text_type)))
734621
def _validate_config(self):
        
        # exit if no backend specified
        if not self.backend:
            return
        # exit if no required config keys
        if len(self.REQUIRED_CONFIG_KEYS) < 1:
            return

        self.config = self.config or {}  # default to empty dict of no config
        required_keys_set = set(self.REQUIRED_CONFIG_KEYS)
        config_keys_set = set(self.config.keys())
        missing_required_keys = required_keys_set - config_keys_set
        unrecognized_keys = config_keys_set - required_keys_set

        # if any missing required key raise ValidationError
        if len(missing_required_keys) > 0:
            # converts list in comma separated string
            missing_keys_string = ', '.join(missing_required_keys)
            # django error
            raise ValidationError(_('Missing required config keys: "%s"') % missing_keys_string)
        elif len(unrecognized_keys) > 0:
            # converts list in comma separated string
            unrecognized_keys_string = ', '.join(unrecognized_keys)
            # django error
            raise ValidationError(_('Unrecognized config keys: "%s"') % unrecognized_keys_string)
1068224
public void checkInvalidParameters() {
    	for(String key: map.keySet()) {
    		boolean wasRequested = requestedKeys != null && requestedKeys.contains(key);
    		if(!wasRequested) throw new IllegalArgumentException("Unknown parameter " + key);
    		
    	}
    }
1275562
private void validateOptions() {
        // No validation if we found a help parameter
        if (helpWasSpecified) {
            return;
        }

        if (!requiredFields.isEmpty()) {
            List<String> missingFields = new ArrayList<>();
            for (ParameterDescription pd : requiredFields.values()) {
                missingFields.add("[" + Strings.join(" | ", pd.getParameter().names()) + "]");
            }
            String message = Strings.join(", ", missingFields);
            throw new ParameterException("The following "
                    + pluralize(requiredFields.size(), "option is required: ", "options are required: ")
                    + message);
        }

        if (mainParameter != null && mainParameter.description != null) {
            ParameterDescription mainParameterDescription = mainParameter.description;
            // Make sure we have a main parameter if it was required
            if (mainParameterDescription.getParameter().required() &&
                    !mainParameterDescription.isAssigned()) {
                throw new ParameterException("Main parameters are required (\""
                        + mainParameterDescription.getDescription() + "\")");
            }

            // If the main parameter has an arity, make sure the correct number of parameters was passed
            int arity = mainParameterDescription.getParameter().arity();
            if (arity != Parameter.DEFAULT_ARITY) {
                Object value = mainParameterDescription.getParameterized().get(mainParameter.object);
                if (List.class.isAssignableFrom(value.getClass())) {
                    int size = ((List<?>) value).size();
                    if (size != arity) {
                        throw new ParameterException("There should be exactly " + arity + " main parameters but "
                                + size + " were found");
                    }
                }

            }
        }
    }
762064
def _validate(self):
        
        errors = []
        for k in self._defaults.keys():
            try:
                validator = self._defaults[k]['validator']
                if validator is not None:
                    self[k] = validator(self[k])
            except ValueError as e:
                errors.append('\t{}: {}'.format(k, six.text_type(e)))

        if errors:
            raise ValueError(
                'Invalid configuration values were set: \n{}'.format('\n'.join(errors)))
592009
def validate_configs(self):
        
        # Check required arguments, validate values
        for conf in self.REQUIRED_CONFIGS:
            if conf not in self._config:
                raise MissingConfigError('Missing required configuration %s' % conf)
997910
def validate_api_response(schema, raw_response, request_method='get', raw_request=None):
    
    request = None
    if raw_request is not None:
        request = normalize_request(raw_request)

    response = None
    if raw_response is not None:
        response = normalize_response(raw_response, request=request)

    if response is not None:
        validate_response(
            response=response,
            request_method=request_method,
            schema=schema
        )
744977
def validate_feature_api(project, force=False):
    """"""
    if not force and not project.on_pr():
        raise SkippedValidationTest('Not on PR')

    validator = FeatureApiValidator(project)
    result = validator.validate()
    if not result:
        raise InvalidFeatureApi
640146
def validate_config(config_json, fields):
    """"""
    for field_name, validator_obj in six.iteritems(fields):
        field_value = config_json.get(field_name, None)
        if field_value is None:
            raise exceptions.ConfigFieldMissing(field_name)

        if not validator_obj.validator_func(field_value):
            raise exceptions.ConfigFieldValidationError(field_name, field_value, validator_obj.get_error_message())
1078726
def _validate_query_parameters(self, query, action_spec):
        
        processed_params = []
        for param_name, param_value in query.items():
            if param_name in action_spec['parameters'].keys():
                processed_params.append(param_name)

                # Check array
                if action_spec['parameters'][param_name]['type'] == 'array':
                    if not isinstance(param_value, list):  # Not an array
                        return False
                    else:
                        for i in param_value:  # Check type of all elements in array
                            if not self.check_type(i, action_spec['parameters'][param_name]['items']['type']):
                                return False

                elif not self.check_type(param_value, action_spec['parameters'][param_name]['type']):
                    return False

        # Check required
        if not all(param in processed_params for param, spec in action_spec['parameters'].items()
                   if spec['in'] == 'query' and 'required' in spec and spec['required']):
            return False
        return True
1141372
def validate_config(data: dict) -> dict:
        """"""
        errors = ConfigSchema().validate(data)
        if errors:
            for field, messages in errors.items():
                if isinstance(messages, dict):
                    for level, sample_errors in messages.items():
                        sample_id = data['samples'][level]['sample_id']
                        for sub_field, sub_messages in sample_errors.items():
                            LOG.error(f"{sample_id} -> {sub_field}: {', '.join(sub_messages)}")
                else:
                    LOG.error(f"{field}: {', '.join(messages)}")
            raise ConfigError('invalid config input', errors=errors)
912760
function validateQueryParams() {
        var queryString;
        if (config.queryParams) {
            if (typeof config.queryParams === 'string') {
                // strip '?' if it's there, because we add it below
                queryString = config.queryParams.replace(/^\?/, '');
            } else {
                queryString = util.param(config.queryParams);
            }
        }
        config.queryString = queryString ? '?' + queryString : '';
    }
1352864
def validate_required_params!(params, *required)
      required.flatten.each do |param|
        if !params.key?(param) || params[param].to_s.empty?
          raise ArgumentError, "Missing required parameter: #{param}."
        end
      end
    end
1265234
public function performValidation()
    {
        $this->requireProperties(['openapi', 'info', 'paths']);
        if (!empty($this->openapi) && !preg_match('/^3\.0\.\d+(-rc\d)?$/i', $this->openapi)) {
            $this->addError('Unsupported openapi version: ' . $this->openapi);
        }
    }
940909
def validate_create_package(
    ctx, opts, owner, repo, package_type, skip_errors, **kwargs
):
    """"""
    click.echo(
        "Checking %(package_type)s package upload parameters ... "
        % {"package_type": click.style(package_type, bold=True)},
        nl=False,
    )

    context_msg = "Failed to validate upload parameters!"
    with handle_api_exceptions(
        ctx, opts=opts, context_msg=context_msg, reraise_on_error=skip_errors
    ):
        with maybe_spinner(opts):
            api_validate_create_package(
                package_format=package_type, owner=owner, repo=repo, **kwargs
            )

    click.secho("OK", fg="green")
    return True
1171979
def _validate_action_parameters(func, params):
    
    if params is not None:
        # Verify field name is valid
        valid_fields = [getattr(fields, f) for f in dir(fields) \
                if f.startswith("FIELD_")]
        for param in params:
            param_name, field_type = param['name'], param['fieldType']
            if param_name not in func.__code__.co_varnames:
                raise AssertionError("Unknown parameter name {0} specified for"\
                        " action {1}".format(
                        param_name, func.__name__))

            if field_type not in valid_fields:
                raise AssertionError("Unknown field type {0} specified for"\
                        " action {1} param {2}".format(
                        field_type, func.__name__, param_name))
343814
def validate(config):
    '''
    
    '''

    # Configuration for load beacon should be a list of dicts
    if not isinstance(config, list):
        return False, ('Configuration for load beacon must be a list.')
    else:
        _config = {}
        list(map(_config.update, config))

        if 'emitatstartup' in _config:
            if not isinstance(_config['emitatstartup'], bool):
                return False, ('Configuration for load beacon option '
                               'emitatstartup must be a boolean.')

        if 'onchangeonly' in _config:
            if not isinstance(_config['onchangeonly'], bool):
                return False, ('Configuration for load beacon option '
                               'onchangeonly must be a boolean.')

        if 'averages' not in _config:
            return False, ('Averages configuration is required'
                           ' for load beacon.')
        else:

            if not any(j in ['1m', '5m', '15m'] for j
                       in _config.get('averages', {})):
                return False, ('Averages configuration for load beacon '
                               'must contain 1m, 5m or 15m items.')

            for item in ['1m', '5m', '15m']:
                if not isinstance(_config['averages'][item], list):
                    return False, ('Averages configuration for load beacon: '
                                   '1m, 5m and 15m items must be '
                                   'a list of two items.')
                else:
                    if len(_config['averages'][item]) != 2:
                        return False, ('Configuration for load beacon: '
                                       '1m, 5m and 15m items must be '
                                       'a list of two items.')

    return True, 'Valid beacon configuration'