Get the request input based on the given validation rules.

@param Request $request
@param array   $rules

@return array
556941
protected function extractInputFromRules(Request $request, array $rules)
    {
        return $request->only(collect($rules)->keys()->map(function ($rule) {
            return Str::contains($rule, '.') ? explode('.', $rule)[0] : $rule;
        })->unique()->toArray());
    }
132566
protected function parseRulesArray(array $rules)
    {
        $parsedRules = [];

        $rawRules = (new ValidationRuleParser($this->data))->explode($rules);

        foreach ($rawRules->rules as $attribute => $attributeRules) {
            foreach ($attributeRules as $attributeRule) {
                $parsedRule = $this->parseRuleString($attributeRule);
                if ($parsedRule) {
                    $parsedRules[$attribute][] = $parsedRule;
                }
            }
        }

        return $parsedRules;
    }
1096485
public function request(Request $request, array $rules, string $group = null, array $messages = [], $default = null): self
    {
        foreach ($rules as $param => $options) {
            $this->validateInput(
                $this->getRequestParam($request, $param, $default),
                new Configuration($options, $param, $group, $default),
                $messages
            );
        }

        return $this;
    }
354129
public function checks(Request $request)
    {
        $defaults = [
            'pass' => ['php' => [], 'system' => []],
            'fail' => ['php' => [], 'system' => []],
        ];
        $checks = MutableBag::fromRecursive([
            'requirements'    => $defaults,
            'recommendations' => $defaults,
        ]);
        /** @var RequirementCollection $baseReqs */
        $baseReqs = $this->app['requirements'];

        foreach ($baseReqs->getRequirements() as $requirement) {
            $result = $requirement->isFulfilled() ? 'pass' : 'fail';
            if ($requirement instanceof PhpConfigRequirement) {
                $checks->get('requirements')->get($result)->get('php')->add($requirement);

                continue;
            }
            $checks->get('requirements')->get($result)->get('system')->add($requirement);
        }
        foreach ($baseReqs->getRecommendations() as $recommendation) {
            $result = $recommendation->isFulfilled() ? 'pass' : 'fail';
            if ($recommendation instanceof PhpConfigRequirement) {
                $checks->get('recommendations')->get($result)->get('php')->add($recommendation);

                continue;
            }
            $checks->get('recommendations')->get($result)->get('system')->add($recommendation);
        }
        $showAll = $request->query->getBoolean('all');

        return $this->render('@bolt/checks/checks.twig', ['checks' => $checks, 'show_all' => $showAll]);
    }
22901
public function getFilters(Request $request): Request
    {
        // check for exist filters in request and get filters
        if (isset($request['filters'])) {
            $filters = json_decode($request['filters'], true);
        } else {
            $filters = [];
        }

        $request[$this->getRequestTagName('filter')] = $filters;

        return $request;
    }
461169
public function matchRequest(Request $request)
    {
        try {
            $parameters = parent::matchRequest($request);
            $this->matchedRouteRequest = $request;
            return $parameters;
        } catch (\Exception $e) {
            throw $e;
        }


    }
72809
private function getRules($rules)
    {
        $rules = [];

        foreach($rules as $rule)
        {
            $rules[] = explode('/', $rule);
        }

        return $rules;
    }
364722
private function evaluateRequestParams($data, $ruleModel)
    {
        foreach ($data as $key => $value) {
            if ($key !== 'form_key' && $key !== 'key' && $key !== 'active_tab') {
                if ($key == 'condition') {
                    if (is_array($value)) {
                        unset($value['__empty']);
                    }
                    $ruleModel->setData('conditions', $value);
                } else {
                    $ruleModel->setData($key, $value);
                }
            }
        }

        return $ruleModel;
    }
1074729
protected function getFilters(Request $request)
    {
        $type = $this->getFilterType($request);

        if (!$type) {
            return $request->query->get('search')['value'];
        }

        $filter = new $type();

        $param = $filter->getBlockPrefix();

        return $request->query->get($param);
    }
983766
private static function validateUserInputs(ContainerInterface $container, array $inputs, string $rulesClass): array
    {
        $errors    = null;
        $validated = null;

        // TODO add csrf
        $isPasswordSame =
            ($inputs[UserSchema::CAPTURE_NAME_PASSWORD] ?? null) ===
            ($inputs[UserSchema::CAPTURE_NAME_PASSWORD_CONFIRMATION] ?? null);

        $validator = self::createFormValidator($container, $rulesClass);
        if ($validator->validate($inputs) === false || $isPasswordSame === false) {
            /** @var Traversable $messages */
            $messages = $validator->getMessages();
            $errors   = iterator_to_array($messages);
            if ($isPasswordSame === false) {
                $formatter = static::createFormatter($container, FluteSettings::VALIDATION_NAMESPACE);

                $errors[UserSchema::CAPTURE_NAME_PASSWORD_CONFIRMATION] =
                    $formatter->formatMessage(ErrorCodes::CONFIRMATION_SHOULD_MATCH_PASSWORD);
            }

            // clear password from inputs
            unset($inputs[UserSchema::CAPTURE_NAME_PASSWORD]);
            unset($inputs[UserSchema::CAPTURE_NAME_PASSWORD_CONFIRMATION]);
        } else {
            $validated = $validator->getCaptures();
            unset($validated[UserSchema::CAPTURE_NAME_PASSWORD_CONFIRMATION]);
        }

        return [$inputs, $validated, $errors];
    }
81499
public function parse( $rules ) {
		if ( is_array( $rules ) ) {
			return $this->parse_array_rules( $rules );
		}

		return $this->parse_string_rules( $rules );
	}
775814
public function validate(Request $request, array $rules, array $messages = [], array $customAttributes = [])
    {
        $validator = $this->getValidationFactory()->make($request->all(), $rules, $messages, $customAttributes);

        if ($validator->fails()) {
            $this->throwValidationException($request, $validator);
        }
    }
952079
public function validate(Request $request, array $rules, array $messages = [], array $attributes = [])
    {
        $this->getValidationFactory()
            ->make($request->all(), $rules, $messages, $attributes)
            ->validate();

        return $this->extractInputFromRules($request, $rules);
    }
473250
public function getRules(NovaRequest $request)
    {
        $result = [];

        foreach ($this->fields as $field) {
            $rules = $this->generateRules($field->getRules($request));

            $result = array_merge_recursive($result, $rules);
        }

        return $result;
    }
72327
public function parse(Request $request)
    {
        foreach($this->rules as $url => $items)
        {
            $result = $this->checkUrl($request, $url, $params);
            if($result['result'] || $result['resultIgnoreCase'])
            {
                foreach($items as $item)
                {
                    if(
                        ($result['result'] || ($this->ignoreCase || $item['annotation']->ignoreCase)) &&
                        $this->checkMethod($request, $item['annotation']->method) &&
                        $this->checkDomain($request, $item['annotation']->domain, $domainParams) &&
                        $this->checkParamsGet($request, $item['annotation']->paramsGet) &&
                        $this->checkParamsPost($request, $item['annotation']->paramsPost) &&
                        $this->checkHeader($request, $item['annotation']->header) &&
                        $this->checkRequestMime($request, $item['annotation']->requestMime)
                    )
                    {
                        $params = array_merge($params, $domainParams);
                        return [
                            'params'        => $params,
                            'callable'      => $this->parseCallable($params, $item['callable']),
                            'middlewares'   => $item['middlewares'] ?? [],
                            'wsConfig'      => $item['wsConfig'],
                        ];
                    }
                }
            }
        }
        return null;
    }
1364250
protected function validatePost($request, $post, $validationRules)
    {
    	$validationRules = $this->validateFieldByConditionalLogic($validationRules, $post, $post);

    	// Lets receive the current items from the post type validation array
    	if(array_key_exists('post_name', $validationRules) && !is_array($validationRules['post_name'])){

	    	$exploded = explode('|', $validationRules['post_name']);

	    	$validationRules['post_name'] = [];

	    	foreach($exploded as $key => $value){
	    		$validationRules['post_name'][] = $value;
	    	}
		}

    	// Lets validate if a post_name is required.
        if(!$post->disableDefaultPostName){

			// If we are edditing the current existing post, we must remove the unique check
			if($request->get('post_name') == $post->post_name){

		    	$validationRules['post_name'] = 'required';

		    // If this is not a existing post name, we need to validate if its unique. They are changing the post name.
		    } else {

		    	// Make sure that only the post_name of the requested post_type is unique
		        $validationRules['post_name'][] = 'required';
		        $validationRules['post_name'][] = Rule::unique('cms_posts')->where(function ($query) use ($post) {
				    return $query->where('post_type', $post->identifier);
				});

		    }

		}

		$validator = Validator::make($request->all(), $validationRules);
        if ($validator->fails()) {
			return [
				'status' => false,
				'errors' => $validator->errors()
			];
        } else {
			return true;
		}
    }
210711
private function isJsonRequestValid(Request $request, $methods)
    {
        $methods = $this->getMethods($methods);

        return ! (
            in_array($request->method(), $methods) &&
            ! $request->isJson()
        );
    }