protected function validate(array $rules, bool $throwError = true)
    {
        $validations = [];
        $data = [];
        foreach ($rules as $key => $rule) {
            $value = $this->request->get($key);
            $violations = $this->validator->validate($value, $rule);
            if (count($violations) > 0) {
                $validations[$key] = [];
                foreach ($violations as $violation) {
                    $validations[$key][] = $violation->getMessage();
                }
            } else {
                $data[$key] = $value;
            }
        }
        if ($throwError && count($validations)) {
            throw new HttpValidationException($validations);
        }
        return $data;
    }
protected function validate(array $rules, bool $throwError = true)
    {
        $validations = [];
        $data = [];
        foreach ($rules as $key => $rule) {
            $value = $this->request->get($key);
            $violations = $this->validator->validate($value, $rule);
            if (count($violations) > 0) {
                $validations[$key] = [];
                foreach ($violations as $violation) {
                    $validations[$key][] = $violation->getMessage();
                }
            } else {
                $data[$key] = $value;
            }
        }
        if ($throwError && count($validations)) {
            throw new HttpValidationException($validations);
        }
        return $data;
    }
protected function validate ( array $ rules , bool $ throwError = true ) { $ validations = [ ] ; $ data = [ ] ; foreach ( $ rules as $ key => $ rule ) { $ value = $ this -> request -> get ( $ key ) ; $ violations = $ this -> validator -> validate ( $ value , $ rule ) ; if ( count ( $ violations ) > 0 ) { $ validations [ $ key ] = [ ] ; foreach ( $ violations as $ violation ) { $ validations [ $ key ] [ ] = $ violation -> getMessage ( ) ; } } else { $ data [ $ key ] = $ value ; } } if ( $ throwError && count ( $ validations ) ) { throw new HttpValidationException ( $ validations ) ; } return $ data ; }
validate input value from request

@param array $rules ['key' => [new NotBlank(), ...], ...]
@param bool $throwError
@return array
@throws HttpValidationException
validate input value from request