Validates Request

 @param    request   [Request]           Request for validation
551448
def validate_request(request)
      validation_errors = []

      validation_errors << 'Request api method is empty'  unless request.api_method
      validation_errors << 'Request end point is empty'   unless request.end_point
      validation_errors << 'Request data is empty'        unless request.request_fields.any?

      unless Validator.validate_by_rule request.gateway_url, Validator::URL, false
        validation_errors << 'Gateway url does not valid in Request'
      end

      if validation_errors.any?
        raise ValidationError, "Some Request fields are invalid:\n#{validation_errors.join(";\n")}"
      end
    end
501662
protected function validateRequest(Request $request)
    {
        $validationErrors = array();

        if (strlen($request->getApiMethod()) == 0)
        {
            $validationErrors[] = 'Request api method is empty';
        }

        if (strlen($request->getEndPoint()) == 0 && strlen($request->getEndPointGroup()) === 0)
        {
            $validationErrors[] = 'Request end point is empty and request end point group is empty. Set one of them.';
        }

        if (strlen($request->getEndPoint()) > 0 && strlen($request->getEndPointGroup()) > 0)
        {
            $validationErrors[] = 'Request end point was set and request end point group was set. Set only one of them.';
        }

        if (count($request->getRequestFields()) === 0)
        {
            $validationErrors[] = 'Request data is empty';
        }

        if (!Validator::validateByRule($request->getGatewayUrl(), Validator::URL, false))
        {
            $validationErrors[] = 'Gateway url does not valid in Request';
        }

        if (!empty($validationErrors))
        {
            throw new ValidationException("Some Request fields are invalid:\n" .
                                          implode(";\n", $validationErrors));
        }
    }
1308187
def validate(self):
        
        endpoint = '/validate'

        payload = dict(accessToken=self.access_token)
        rep = self._ygg_req(endpoint, payload)
        return not bool(rep)
1322988
public boolean validateCrumb(ServletRequest request) {
        CrumbIssuerDescriptor<CrumbIssuer> desc = getDescriptor();
        String crumbField = desc.getCrumbRequestField();
        String crumbSalt = desc.getCrumbSalt();

        return validateCrumb(request, crumbSalt, request.getParameter(crumbField));
    }
1228593
def _validate_request(endpoint, file_type='json', data=None, params=None):
        
        if not isinstance(endpoint, string_types) or endpoint.strip() == '':
            raise ClientException("Must submit `endpoint` for DHIS2 API")
        if not isinstance(file_type, string_types) or file_type.lower() not in ('json', 'csv', 'xml', 'pdf', 'xlsx'):
            raise ClientException("Invalid file_type: {}".format(file_type))
        if params:
            if not isinstance(params, (dict, list)):
                raise ClientException("`params` must be a dict or list of tuples, not {}".format(params.__class__.__name__))
            if isinstance(params, list) and not all([isinstance(elem, tuple) for elem in params]):
                raise ClientException("`params` list must all be tuples")
        if data and not isinstance(data, dict):
            raise ClientException("`data` must be a dict, not {}".format(data.__class__.__name__))
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) {}
        }
      }
    }
  }
952967
def _process_request(request)
      _error!(Errors::NotFoundError) unless request.valid?
      _validate_version(request)
      retval = _call_method(request)
      _response(request.post? ? 201 : 200, _prepare_response(retval))
    end
873521
def filter_request(request)
      @filters.each do |filter|
        request = filter.filter(request)
        return nil if request.nil?
      end
      request
    end
472248
private function validateEmail(Request $request)
    {
        $email = self::$validator->isString('email');

        $result = $email
            ->isRequired()
            ->isEmail()
            ->validate($request->email);

        $this->isValid = $this->isValid && $result;
        $this->errors  = array_merge($this->errors, $email->getErrors());
    }
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
}
629975
public function parse(Request $request)
    {
        if ($request->has($this->name)) {
            $this->applied = true;
            $this->value   = filter_var($request->input($this->name), FILTER_VALIDATE_BOOLEAN);
        }
    }
1180151
def validate_incoming_request
      unless request.media_type == Rack::Mime.mime_type('.json')
        error_msg = ServiceError.new(ServiceError::INVALID_CONTENT).to_hash
        logger.error("Validation failure: #{error_msg.inspect}, request media type: #{request.media_type} is not json")
        abort_request(error_msg)
      end
      unless auth_token && (auth_token == @token)
        error_msg = ServiceError.new(ServiceError::NOT_AUTHORIZED).to_hash
        logger.error("Validation failure: #{error_msg.inspect}, expected token: #{@token}, specified token: #{auth_token}")
        abort_request(error_msg)
      end
      unless @handle_fetched
        error_msg = ServiceError.new(ServiceError::SERVICE_UNAVAILABLE).to_hash
        logger.error("Validation failure: #{error_msg.inspect}, handles not fetched")
        abort_request(error_msg)
      end
    end
1262767
def read_validate_params(self, request):
        
        self.client = self.client_authenticator.by_identifier(request)

        response_type = request.get_param("response_type")

        if self.client.response_type_supported(response_type) is False:
            raise OAuthInvalidError(error="unauthorized_client")

        self.state = request.get_param("state")

        self.scope_handler.parse(request, "query")

        return True
758985
public void verifyEmail(VerifyEmailRequest request) {
        checkNotNull(request, "object request should not be null.");
        assertStringNotNullOrEmpty(request.getEmailAddress(), "object emailAddress should not be null or empty");

        InternalRequest internalRequest =
                this.createRequest("verifiedEmail", request, HttpMethodName.PUT, request.getEmailAddress());

        this.invokeHttpClient(internalRequest, SesResponse.class);
    }
411829
public boolean isValid(HttpServletRequest request, CaptchaRequest captcha) {
    String challenge = captcha.getRecaptcha_challenge_field();
    String response = captcha.getRecaptcha_response_field();    
    return isValid(request, challenge, response);
  }
691295
def validate(self, request, response):
        
        element = self.search_response(request)
        if element is not None:
            element.cached_response.options = response.options
            element.freshness = True
            element.max_age = response.max_age
            element.creation_time = time.time()
            element.uri = request.proxy_uri
282832
def validate_scopes(self, request):
        
        if not request.scopes:
            request.scopes = utils.scope_to_list(request.scope) or utils.scope_to_list(
                self.request_validator.get_default_scopes(request.client_id, request))
        log.debug('Validating access to scopes %r for client %r (%r).',
                  request.scopes, request.client_id, request.client)
        if not self.request_validator.validate_scopes(request.client_id,
                                                      request.scopes, request.client, request):
            raise errors.InvalidScopeError(request=request)