Validate the given request with the given rules.

@param  \Illuminate\Http\Request  $request
@param  array  $rules
@param  array  $messages
@param  array  $customAttributes
@return void

@throws \Illuminate\Http\Exception\HttpResponseException
502582
public function validate(AbstractValidator $validator, $removeRequired = false, array $messages = [], array $customAttributes = [])
    {
        return $validator->validate($removeRequired);
        /*try {
            return $validator->validate($removeRequired);
        } catch (ValidationException $e) {
            $this->throwValidationException($e->getErrors());
        }*/

//              $this->throwValidationException($request, $validator);
        // $validator = $this->getValidationFactory()->make($request->all(), $rules, $messages, $customAttributes);

    }
906252
public function validate(array $params, array $rules, array $messages = [])
    {
        $validator = app(Validator::class)->make($params, $rules, $messages);

        if ($validator->fails()) {
            throw new ValidationException(
                $validator, new JsonResponse($validator->errors()->getMessages(), 422)
            );
        }
    }
1131014
protected function validateAttributes()
    {
        if (empty($this->getRules())) return;

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

            throw (new FilterDataValidationFailedException)->setMessages($this->messages());
        }
    }
507147
public static function make(array $data, array $rules, $unknown = null, $custom = [])
  {
    $factory = new ValidatorFactory();

    if (is_array($unknown) && count($unknown) > 0) {
      $custom = $unknown;
    }

    $response = $factory->make($data, $rules, $custom);

    if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) &&
      strtoupper($_SERVER['HTTP_X_REQUESTED_WITH']) === 'XMLHTTPREQUEST' &&
      $response->fails()) {
        return Rest::response()
                    ->json($response->errors()->toArray(), 422);

        die();
    }

    return $response;
  }
969735
public function convert(Validation $validation, $format, array $keyTitles = [], array $customMessages = [])
    {

        if (!in_array($format, $this->supportedFormats)) {
            throw new UnsupportedParameterException(static::class . ' only supports MessageBag');
        }

        $messages = new MessageBag;

        if (!count($validation)) {
            return $messages;
        }

        foreach ($validation as $key=>$rules) {
            foreach ($rules as $ruleName=>$parameters) {
                $message = $this->getMessage($key, $ruleName, $rules, $keyTitles, $customMessages);
                $messages->add($key, $message);
            }
        }

        return $messages;

    }
1203984
protected function validate_use_validator( array $data, array $rules ) {
		if ( empty( $rules ) ) {
			return;
		}

		$validator = new Validator( $data, $rules );

		$validator->labels(
			$this->fields->pluck( 'name', 'id' )->all()
		);

		if ( $validator->fails() ) {
			foreach ( $rules as $key => $rule ) {
				$this->add_error( $key, $validator->errors( $key ) );
			}
		}
	}
651338
protected function validate($data, $rules)
    {
        $data = array_filter($data);

        $validator = $this->validator->make($data, $rules);

        if ($validator->fails()) {
            throw new PagSeguroException($validator->messages()->first(), 1003);
        }
    }
307572
protected function validate(array $rules, $values = null, array $customAttrs = [])
    {
        // Se os valores forem nulos, buscar no request
        if (is_null($values)) {
            $values = request()->all();
        }

        // Validar valores pela regra
        return Validator::validate($values, $rules, $customAttrs);
    }
425729
public static function validate($request, $rules, $messages=[])
    {
        $errors = [];
        $files = $request->getUploadedFiles();

        foreach ($rules as $field => $rule)
        {
            try
            {
                if ($rule instanceof v)
                {
                    // check if the field is for file
                    if (isset($files[$field]))
                    {
                        if (is_array($files[$field])) // multiple file
                        {
                            $files = $files[$field];
                            foreach ($files as $file_row)
                            {
                                if ($file_row instanceof UploadedFile)
                                {
                                    $rule->setName(str_title(ucfirst($field)))->assert(new \SplFileInfo($file_row->file));
                                }
                            }
                        }
                        else // single file
                        {
                            if ($files[$field] instanceof UploadedFile)
                            {
                                $rule->setName(str_title(ucfirst($field)))->assert(new \SplFileInfo($files[$field]->file));
                            }
                        }
                    }
                    else
                    {
                        $rule->setName(str_title(ucfirst($field)))->assert($request->getParam($field));
                    }
                }
                else
                {
                    \Log::error("Error: Rule must be Respect\Validation\Validator object");
                }
            } catch (NestedValidationException $e) {
                $translator = config('validation.translator');
                $e->setParam('translator', function($message) use($translator) {
                    $language = $translator['lang'];
                    $messages = $translator['messages'];

                    return isset($messages[$message]) ? $messages[$message][$language] : $message;
                });

                $e->findMessages($messages);
                $errors[$field] = $e->getMessages();
            }
        }
        Session::set('errors', $errors);
        return __CLASS__;
    }
476810
public function validate(array $data, array $rules, array $messages = [], array $customAttributes = [])
    {
        return $this->make($data, $rules, $messages, $customAttributes)->validate();
    }
892149
public function setRules(array $rules)
    {
        $this->validators = [];
        foreach ($rules as $rule) {
            if (is_array($rule[0]) && is_string($rule[1])) {
                continue;
            }
            throw new InvalidArgumentException('Bad validation rule');
        }
        $this->rules = $rules;

        return $this;
    }
1314567
public function validate(BaseModel $model, $rules = null, $messages = [])
    {
        return $this->validateAndPrefixErrors(null, $model, $rules, $messages);
    }
621996
public function make(array $data, array $rules, array $messages = array(), array $customAttributes = array())
	{
		// The presence verifier is responsible for checking the unique and exists data
		// for the validator. It is behind an interface so that multiple versions of
		// it may be written besides database. We'll inject it into the validator.
		$validator = $this->resolve($data, $rules, $messages, $customAttributes);

		if ( ! is_null($this->verifier))
		{
			$validator->setPresenceVerifier($this->verifier);
		}

		// Next we'll set the IoC container instance of the validator, which is used to
		// resolve out class based validator extensions. If it is not set then these
		// types of extensions will not be possible on these validation instances.
		if ( ! is_null($this->container))
		{
			$validator->setContainer($this->container);
		}

		$this->addExtensions($validator);

		return $validator;
	}
407304
public function sometimes( $attribute, $rules, callable $callback )
	{
		$payload = new Fluent( $this->attributes() );

		if ( call_user_func( $callback, $payload ) )
		{
			foreach ( (array) $attribute as $key )
			{
				if ( Str::contains( $key, '*' ) )
				{
					$this->explodeRules( [$key => $rules] );
				}
				else
				{
					$this->mergeRules( $key, $rules );
				}
			}
		}
	}
687123
protected function validate($input, array &$messages)
    {
        /** @var IUploadedFile $input */

        if (!$input->hasUploadedSuccessfully()) {
            if (!isset(self::$errorMap[$input->getUploadError()])) {
                throw InvalidArgumentException::format('Unknown file upload error: \'%s\'', $input->getUploadError());
            }

            $messages[] = new Message(self::$errorMap[$input->getUploadError()]);
        }
    }
1326180
protected function _validate($attribute, $rule, $parameters, $value)
    {
        $srcValue = $value;

        if (isset($this->_validators[$rule])) {
            /** @noinspection VariableFunctionsUsageInspection */
            $value = call_user_func_array($this->_validators[$rule], [$value, $parameters]);
        } elseif (function_exists($rule)) {
            $value = call_user_func_array($rule, array_merge([$value], $parameters));
        } else {
            throw new FilterException(['`:name` rule is not be recognized', 'name' => $rule]);
        }

        if ($value === null) {
            if (is_string($this->_messages)) {
                if (strpos($this->_messages, '.') === false) {
                    $file = '@manaphp/Http/Validator/Messages/' . $this->_messages . '.php';
                } else {
                    $file = $this->_messages;
                }

                if (!$this->filesystem->fileExists($file)) {
                    throw new FilterException(['`:file` rule message template file is not exists', 'file' => $file]);
                }

                /** @noinspection PhpIncludeInspection */
                $this->_messages = require $this->alias->resolve($file);
            }

            if (isset($this->_messages[$rule])) {
                $message = [$this->_messages[$rule]];
            } else {
                $message = [$this->_defaultMessage];
            }

            $message['rule'] = $rule;
            $message['attribute'] = isset($this->_attributes[$attribute]) ? $this->_attributes[$attribute] : $attribute;
            $message['value'] = $srcValue;
            foreach ($parameters as $k => $parameter) {
                $message['parameters[' . $k . ']'] = $parameter;
            }

            throw new FilterException($message);
        }

        return $value;
    }
1290752
public function validate(array $data, array $rules, array $messages = [])
	{
		// Build the validator.
		$validator = $this->validationFactory->make($data, $rules, $messages);

		// Return the errors, if any.
		if($validator->fails())
		{
			return new Payload($validator->messages(), 'invalid');
		}

		return new Payload($data, 'valid');
	}