Make sure that the request contains no logical errors
199730
private function sanitizeRequest()
    {
        // The label filter does not work with expanded=1 because the data table IDs have a different meaning
        // depending on whether the table has been loaded yet. expanded=1 causes all tables to be loaded, which
        // is why the label filter can't descend when a recursive label has been requested.
        // To fix this, we remove the expanded parameter if a label parameter is set.
        if (isset($this->request['label']) && !empty($this->request['label'])
            && isset($this->request['expanded']) && $this->request['expanded']
        ) {
            unset($this->request['expanded']);
        }
    }
52502
def validate_for_request(self):
        """"""
        if not self.use_packages and not self.modules and not self.pulp:
            raise ValueError("Nothing to compose (no packages, modules, or enabled pulp repos)")

        if self.packages and not self.koji_tag:
            raise ValueError('koji_tag is required when packages are used')
818167
def assert_valid(self):
        """"""

        for ns_uri, ni in six.iteritems(self.__ns_uri_map):
            if not ni.uri:
                raise InvalidNamespaceSetError(
                    "URI not set in _NamespaceInfo (id={0}):\n{1}".format(
                        id(ni), ni
                    )
                )

            if ns_uri != ni.uri:
                raise InvalidNamespaceSetError(
                    "URI mismatch in dict ({0}) and _NamespaceInfo ({1})".format(
                        ns_uri, ni.uri
                    )
                )

            if (ni.preferred_prefix is not None and
               ni.preferred_prefix not in ni.prefixes):
                raise InvalidNamespaceSetError(
                    "Namespace {0.uri}: preferred prefix " \
                    '"{0.preferred_prefix}" not in prefixes ' \
                    "{0.prefixes}".format(ni)
                )

            for prefix in ni.prefixes:
                if not prefix:
                    raise InvalidNamespaceSetError(
                        "Namespace {0.uri}: empty value in prefix " \
                        "set: {0.prefixes}".format(ni)
                    )
                other_ni = self.__prefix_map.get(prefix)
                if other_ni is None:
                    raise InvalidNamespaceSetError(
                        'Namespace {0.uri}: prefix "{1}" not in ' \
                        'prefix map'.format(ni, prefix)
                    )
                if other_ni is not ni:
                    raise InvalidNamespaceSetError(
                        'Namespace {0.uri}: prefix "{1}" maps to ' \
                        'wrong _NamespaceInfo (id={2}, uri={3.uri})'.format(
                            ni, prefix, id(other_ni), other_ni
                        )
                    )

        if None in self.__prefix_map:
            # None can be a preferred prefix, but should not be in the
            # prefix map.
            raise InvalidNamespaceSetError("None is in prefix map!")
775623
def _sanitize_request_params(self, request_params):
        """"""
        if 'verify_ssl' in request_params:
            request_params['verify'] = request_params.pop('verify_ssl')
        return dict((key, val) for key, val in request_params.items()
                    if key in self._VALID_REQUEST_ARGS)
699787
private void validateRequest(CmdbRequest request) throws HygieiaException {
        String busServiceName = request.getConfigurationItemBusServName();
        if(!StringUtils.isEmpty( busServiceName ) && cmdbRepository.findByConfigurationItemAndItemType( busServiceName, APP_TYPE ) == null){
            throw new HygieiaException("Configuration Item " + busServiceName + " does not exist", HygieiaException.BAD_DATA);
        }

        Cmdb cmdb = cmdbRepository.findByConfigurationItemIgnoreCaseOrCommonNameIgnoreCase(request.getConfigurationItem(), request.getCommonName());
        if(cmdb != null){
            throw new HygieiaException("Configuration Item " + cmdb.getConfigurationItem() + " already exists", HygieiaException.DUPLICATE_DATA);
        }

        List<Collector> collectors = collectorRepository.findByCollectorTypeAndName(CollectorType.CMDB, request.getToolName());
        if (CollectionUtils.isEmpty(collectors)) {
            throw new HygieiaException(request.getToolName() + " collector is not available.", HygieiaException.BAD_DATA);
        }
    }
1189294
def ok(no_exit, func, *args, **kwargs):
    """"""
    ret = func(*args, **kwargs)
    if no_exit or ret >= 0:
        return ret
    reason = errmsg[abs(ret)]
    error('{0}() returned {1} ({2})'.format(func.__name__, ret, reason))
249459
def check_in(request, action):
    """"""
    if not request:
        req_str = ""
        for idx, val in enumerate(actions[action]):
            req_str += "\n" + val
        erstr = "Provide a request dict with the following properties:" \
                " %s" % req_str
        raise ValueError(erstr)

    required_fields = actions[action]
    missing = []
    for field in required_fields:
        if not is_key_present(request, field):
            missing.append(field)
    if missing:
        missing_string = ""
        for idx, val in enumerate(missing):
            missing_string += "\n" + val
        erstr = "Provide the required request parameters to" \
                " complete this request: %s" % missing_string
        raise ValueError(erstr)

    return True
934611
public function isValid (Request $request)
		{
			$parsed = $this->parseRouteRequest($request);

			return $this->getBaseUri($request) !== null
				&& preg_match('#^' . preg_quote(rtrim($this->getBaseUri($request), '/'), '#') . '#', rtrim($request->getUri(false), '/'))
				&& $this->getController($request)->respondsTo($parsed['method'], $parsed['arguments']);
		}
425062
def validate_steps(self, request, workflow, start, end):
        
        errors = {}
        for step in workflow.steps[start:end + 1]:
            if not step.action.is_valid():
                errors[step.slug] = dict(
                    (field, [six.text_type(error) for error in errors])
                    for (field, errors) in step.action.errors.items())
        return {
            'has_errors': bool(errors),
            'workflow_slug': workflow.slug,
            'errors': errors,
        }
189332
function mandatoryCheck (params = {}) {
        assert.ok(params.host !== void 0, 'no host given');
        assert.ok(params.path !== void 0, 'no path given');
        assert.ok(params.wsdl !== void 0, 'no wsdl given');
    }
874453
private void checkSerialize(final HttpServletRequest request) {
    String reqpar = request.getParameter("serialize");

    if (reqpar == null) {
      return;
    }

    HttpSession sess = request.getSession(false);
    Enumeration en = sess.getAttributeNames();

    while (en.hasMoreElements()) {
      String attrname = (String)en.nextElement();
      ObjectOutputStream oo = null;

      info("Attempt to serialize attr " + attrname);
      Object o = sess.getAttribute(attrname);

      try {
        ByteArrayOutputStream bo = new ByteArrayOutputStream();
        oo = new ObjectOutputStream(bo);
        oo.writeObject(o);
        oo.flush();

        info("Serialized object " + attrname + " has size: " + bo.size());
      } catch (Throwable t) {
        t.printStackTrace();
      } finally {
        if (oo != null) {
          try {
            oo.close();
          } catch (Throwable t) {}
        }
      }
    }
  }
381177
def validate_service(self, request, uid):
        
        spec_min = get_record_value(request, uid, "min")
        spec_max = get_record_value(request, uid, "max")
        error = get_record_value(request, uid, "error", "0")
        warn_min = get_record_value(request, uid, "warn_min")
        warn_max = get_record_value(request, uid, "warn_max")

        if not spec_min and not spec_max:
            # Neither min nor max values have been set, dismiss
            return None

        if not api.is_floatable(spec_min):
            return "'Min' value must be numeric"
        if not api.is_floatable(spec_max):
            return "'Max' value must be numeric"
        if api.to_float(spec_min) > api.to_float(spec_max):
            return "'Max' value must be above 'Min' value"
        if not api.is_floatable(error) or 0.0 < api.to_float(error) > 100:
            return "% Error must be between 0 and 100"

        if warn_min:
            if not api.is_floatable(warn_min):
                return "'Warn Min' value must be numeric or empty"
            if api.to_float(warn_min) > api.to_float(spec_min):
                return "'Warn Min' value must be below 'Min' value"

        if warn_max:
            if not api.is_floatable(warn_max):
                return "'Warn Max' value must be numeric or empty"
            if api.to_float(warn_max) < api.to_float(spec_max):
                return "'Warn Max' value must be above 'Max' value"
        return None
969106
function checkErrors(response, xhrErrors) {
    let { status, ok } = response;
    if (!ok) {
        if (xhrErrors[status]) {
            xhrErrors[status](response);
        }
    }
}
1083272
def _check_valid(key, val, valid):
    """"""
    if val not in valid:
        raise ValueError('%s must be one of %s, not "%s"'
                         % (key, valid, val))
319128
def error(request, message, extra_tags='', fail_silently=False, async=False):
    """"""
    if ASYNC and async:
        messages.debug(_get_user(request), message)
    else:
        add_message(request, constants.ERROR, message, extra_tags=extra_tags,
                    fail_silently=fail_silently)
1277285
def verify_request(self, uri, http_method='GET', body=None, headers=None,
                       scopes=None):
        """"""
        request = Request(uri, http_method, body, headers)
        request.token_type = self.find_token_type(request)
        request.scopes = scopes
        token_type_handler = self.tokens.get(request.token_type,
                                             self.default_token_type_handler)
        log.debug('Dispatching token_type %s request to %r.',
                  request.token_type, token_type_handler)
        return token_type_handler.validate_request(request), request
372716
function validateRequest (data, requestMethod) {
  if (!data.data) {
    return 'JSON API resource object must contain `data` property'
  }

  if (!data.data.type) {
    return 'JSON API resource object must contain `data.type` property'
  }

  if (['PATCH', 'PUT'].indexOf(requestMethod) > -1 && !data.data.id) {
    return 'JSON API resource object must contain `data.id` property'
  }

  return false
}