Validate the given request with the given rules.

@param  \Illuminate\Http\Request $request
@param  array $rules
@param  array $messages
@param  array $customAttributes
@return void
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);
        }
    }
973314
public function validate($values, array $ruleSet, string $prefix = null) : bool
    {
        // If there are no rules, there is nothing to validate
        if(empty($ruleSet)) {
            return true;
        }
        if ($prefix !== null) {
            $this->prefix .= $prefix . '.';
        }

        // For each pattern and its rules
        foreach ($ruleSet as $pattern => $rules) {
            if (is_string($rules)) {
                $rules = explode('|', $rules);
            }
            foreach ($rules as $rule) {
                list($rule, $parameters) = array_pad(explode(':', $rule, 2), 2, '');
                $parameters = array_map('trim', explode(',', $parameters));

                if (Arr::exists($this->rules, $rule)) {
                    call_user_func($this->rules[$rule], $this, $values, $pattern, $rule, $parameters);
                }
            }
        }
        $this->prefix = '';

        return $this->hasErrors();
    }
1131014
protected function validateAttributes()
    {
        if (empty($this->getRules())) return;

        if ( ! $this->validate()) {

            throw (new FilterDataValidationFailedException)->setMessages($this->messages());
        }
    }
1111987
protected function validatePost($postTypeModel, $request, $validationRules)
    {
    	// 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(!$postTypeModel->disableDefaultPostName){

        	// 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 ($postTypeModel) {
			    return $query->where('post_type', $postTypeModel->identifier);
			});

        }

        return $this->validate($request, $validationRules);
    }
144876
public function validationRules(array $rules = array())
    {
        if (empty($rules)) {
            return $this->validationRules;
        }

        $this->validationRules = $rules;

        return $this;
    }
264683
protected function validate(array $input, array &$messages)
    {
        if (!call_user_func_array($this->validationCallback, [$input, &$messages])) {
            if ($this->messageId) {
                $messages[] = new Message($this->messageId, $this->messageParameters);
            }
        }
    }
940794
private function validateData($rules, $data) {
		$errors = [];
		foreach ($rules as $field => $rule) {
			$valid = $this->validateField($field, $data, $rule);
			if ($valid !== true) {
				$errors[ $field ] = $valid;
			}
		}
		if (!empty($errors)) {
			throw new ValidateException($errors);
		}

		return true;
	}
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;
    }
1314567
public function validate(BaseModel $model, $rules = null, $messages = [])
    {
        return $this->validateAndPrefixErrors(null, $model, $rules, $messages);
    }
692772
protected function validate(array $data, array $rules)
    {
        $validator = $this->validator->make($data, $rules);
        if ($validator->fails()) {
            throw new ValidationException($validator);
        }
        return $this;
    }
600529
public function validate(array $rules = [], array $messages = [], bool $merge = true) : bool
    {
        if ($merge) {
            $rules = array_merge($this->rules(), $rules);
            $messages = array_merge($this->defaultMessages, $this->messages(), $messages);
        }
        $rules = $this->uniqueUpdates($rules);
        $validation = LaravelValidator::make($this->input, $rules, $messages);
        if ($validation->fails()) {
            $this->validation = $validation;
            return false;
        } else {
            $this->validation = false;
            return true;
        }
    }
325165
public function validateContext($data, $rules)
	{
		// Init base return values.
		$returnStatus = 'valid';
		$returnData   = null;

		// We only need to validate context if context rules are configured.
		if(array_key_exists('context', $rules))
		{
			foreach($rules['context'] as $rule)
			{
				switch($rule)
				{
					case 'EXAMPLE':
						if(1 !== 2)
						{
							$returnStatus = $rule;
						}
					break;

					default:
					break;
				}
			}
		}

		// Check for any configured custom validation messages.
		if($returnStatus != 'valid')
		{
			if(array_key_exists($returnStatus, $this->messages))
			{
				$data = $this->messages[$returnStatus];
			}
		}

		return new Payload($data, $returnStatus);
	}
1135155
public function save(array $rules = array(),
        array $customMessages = array(),
        array $options = array(),
        Closure $beforeSave = null,
        Closure $afterSave = null
    ) {
        return $this->internalSave($rules, $customMessages, $options, $beforeSave, $afterSave, false);
    }
733258
protected function validatePost($request, $post, $validationRules)
	{
		$currentValidationRuleKeys = [];
		foreach($request->all() as $requestKey => $requestValue){
			$currentValidationRuleKeys[$requestKey] = $requestKey;
		}

		$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);
				});

			}

		}

		$newValidationRules = [];
		foreach($currentValidationRuleKeys as $finalKeys => $finalValues){
			if(array_key_exists($finalKeys, $validationRules)){
				$newValidationRules[$finalKeys] = $validationRules[$finalKeys];
			}
		}

		return $this->validate($request, $newValidationRules);
	}
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);
    }
1024802
public function addRules($rules)
    {
        // The primary purpose of this parser is to expand any "*" rules to the all
        // of the explicit rules needed for the given data. For example the rule
        // names.* would get expanded to names.0, names.1, etc. for this data.
        $response = (new ValidationRuleParser($this->data))
                            ->explode($rules);

        $this->rules = array_merge_recursive(
            $this->rules, $response->rules
        );

        $this->implicitAttributes = array_merge(
            $this->implicitAttributes, $response->implicitAttributes
        );
    }
954637
public function validate($rules = [], $errors = [])
    {
        foreach ($rules as $param => $subRules) {
            $paramValue = $this->getParam($param);
            foreach ($subRules as $key => $rule) {
                $isError = false;
                if (!is_array($rule)) {
                    switch ($rule) {
                        case self::VALIDATE_REQUIRED:
                            if (is_null($paramValue)) {
                                $isError = true;
                            }
                            break;
                        case self::VALIDATE_MOBILE:
                            if (!ValidationHelper::isMobile($paramValue)) {
                                $isError = true;
                            }
                            break;
                    }
                } else {
                    switch ($key) {
                    case self::VALIDATE_ENUM:
                        if (!in_array($paramValue, $rule)) {
                            $isError = true;
                        }
                        break;
                    }
                }
                if ($isError) {
                    $errCode = self::ERROR_INVALID_PARAM;
                    $errMsg = self::errorMsg[self::ERROR_INVALID_PARAM];
                    if (is_array($rule)) {
                        $rule = $key;
                    }
                    if (isset($errors[$param][$rule]['code'])) {
                        $errCode = $errors[$param][$rule]['code'];
                    }
                    if (isset($errors[$param][$rule]['msg'])) {
                        $errMsg = str_replace('{param}', $param, $errors[$param][$rule]['msg']);
                    }
                    throw new ParamException($errMsg, $errCode);
                }
            }
        }
    }