Put all fails in session
@param  Psr\Http\Message\RequestInterface $request
@param  array $rules
@return SkeletonCore\Utilities\Validator
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__;
    }
227498
public function create(array $input, array $rules): Validator
	{
		$validator = new Validator($input, $rules, $this->i18n, $this->container);

		foreach($this->rules as $rule => $ruleClass)
		{
			$validator->extend($rule, $ruleClass);
		}

		return $validator;
	}
967831
private function validatePriorities(Request $request): void
    {
        $this->validate(
            $request->request->get('rule_ids'),
            [
                new Constraints\NotBlank(),
                new Constraints\Type(['type' => 'array']),
                new Constraints\All(
                    [
                        'constraints' => [
                            new Constraints\NotBlank(),
                            new Constraints\Type(['type' => 'scalar']),
                        ],
                    ]
                ),
            ],
            'rule_ids'
        );
    }
352154
public function validate(array $rules = array(), array $customMessages = array()) {
        if ($this->fireModelEvent('validating') === false) {
            if ($this->throwOnValidation) {
                throw new InvalidModelException($this);
            } else {
                return false;
            }
        }

        // check for overrides, then remove any empty rules
        $rules = (empty($rules))? static::$rules : $rules;
        foreach ($rules as $field => $rls) {
            if ($rls == '') {
                unset($rules[$field]);
            }
        }

        if (empty($rules)) {
            $success = true;
        } else {
			$customMessages = (empty($customMessages))? static::$customMessages : $customMessages;

			if ($this->forceEntityHydrationFromInput || (empty($this->attributes) && $this->autoHydrateEntityFromInput)) {
				$this->fill(Input::all());
			}

			$data = $this->getAttributes(); // the data under validation

			// perform validation
			$validator = static::makeValidator($data, $rules, $customMessages);
			$success   = $validator->passes();

			if ($success) {
				// if the model is valid, unset old errors
				if ($this->validationErrors->count() > 0) {
					$this->validationErrors = new MessageBag;
				}
			} else {
				// otherwise set the new ones
				$this->validationErrors = $validator->messages();

				// stash the input to the current session
				if (!self::$externalValidator && Input::hasSession()) {
					Input::flash();
				}
			}
		}

        $this->fireModelEvent('validated', false);

	    if (!$success && $this->throwOnValidation) {
		    throw new InvalidModelException($this);
	    }

        return $success;
    }
996036
public function setRules(array $rules)
    {
        foreach ($rules as $key => $values) {

            if ((is_array($values) === true && empty($values) === false) || is_callable($values)) {
                $this->rules[$key] = $values;
            } else {
                $this->rules[$key] = trim($values);
            }
        }

        return $this;
    }
36493
public function make($data, $rules)
    {
        $result = app('validator')->make($data, $rules);
        if ($result->fails()) {
            $this->errors = $result->messages()->toArray();
            return false;
        }
        $this->reset();
        return true;
    }
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);
        }
    }
1173639
public function validate(Request $request, array $rules, array $messages = [], array $customAttributes = [])
    {
        // Check for previous errors
        if ($this->hasPreValidationErrors()) {
            $validator = Validator::make([], []);
            foreach ($this->errors as $field => $error) {
                $validator->errors()->add($field, $error);
            }
            $this->throwValidationException($request, $validator);
        }

        if ($this->injectUserId && 'index' !== $this->method) {
            $rules['user_id'] = 'required|in:' . Auth::id();
        }

        parent::validate($request, $rules, $messages, $customAttributes);
    }
537087
public function put($pattern, $action)
    {
        self::$rules[self::REQUEST_METHOD_PUT . self::patternFactory($pattern)] = $action;
        return $this;
    }
605385
public function assertSessionHasErrors($bindings = [], $format = null)
    {
        $this->assertSessionHas('errors');

        $bindings = (array) $bindings;

        $errors = $this->app['session.store']->get('errors');

        foreach ($bindings as $key => $value) {
            if (is_int($key)) {
                PHPUnit::assertTrue($errors->has($value), "Session missing error: $value");
            } else {
                PHPUnit::assertContains($value, $errors->get($key, $format));
            }
        }
    }
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;
	}
1302282
public function addRules($rules)
    {
        if ($rules instanceof RiskyRulesAwareInterface && $rules->isRisky()) {
            $this->setRiskyAllowed(true);
        }

        if ($rules instanceof \Traversable) {
            $rules = iterator_to_array($rules);
        }

        if (!is_array($rules)) {
            throw new \InvalidArgumentException('Expected rules to be an iterable.');
        }

        $rules = array_replace($this->getRules(), $rules);

        $this->setRules($rules);

        return $this;
    }
990603
public function storeRuleFailed(array $errors)
    {
        $url     = handles('antares::ban_management/rules/datatable');
        $message = trans('antares/ban_management::response.rules.create.db-failed', $errors);

        return $this->redirectWithMessage($url, $message, 'error');
    }
575968
public function validate(array $values, array $rules)
    {
        // Assume no validation and result success
        $result = true;

        if (true !== $valid = $this->validateByRules($rules, $values)) {
            foreach ($valid as $componentName => $error) {
                $this->setError($error, $componentName);
            }

            // Set general form error
            $this->setError(
                [
                    'error' => 'general',
                    'info'  => [],
                ],
                Doozr_Form_Service_Constant::ERROR_IDENTIFIER_FORM
            );

            $result = false;
        }

        return $result;
    }
1178546
public static function validator(array $rules = [], ContainerInterface $container = null): self
    {
        $validator = new static($rules, $container);

        return $validator;
    }
121250
public function validate(Request $request, array $rules = [], array $filters = [])
    {
        $all = $request->all();

        return $request->getValidation()->make($all, $rules, $filters);
    }
1189930
public function addRules(array $rules, $ruleset = null)
    {
        if ($ruleset) {
            $newRules = array_merge($this->getRuleset($ruleset), $rules);
            $this->setRuleset($newRules, $ruleset);
        } else {
            $newRules = array_merge($this->getRules(), $rules);
            $this->setRules($newRules);
        }
    }