From 4f4c9a8f8209c684b087a37b74fe1f5496147555 Mon Sep 17 00:00:00 2001 From: lilin <794774870@qq.com> Date: Wed, 21 Mar 2018 19:46:07 +0800 Subject: [PATCH] validator default --- src/Http/HttpServer.php | 1 + src/Validator/HttpValidator.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/Http/HttpServer.php b/src/Http/HttpServer.php index aac5979..e7be468 100644 --- a/src/Http/HttpServer.php +++ b/src/Http/HttpServer.php @@ -31,6 +31,7 @@ public function start() if (!empty($this->setting['open_http2_protocol'])) { $this->httpSetting['type'] = SWOOLE_SOCK_TCP|SWOOLE_SSL; } + $this->server = new Server($this->httpSetting['host'], $this->httpSetting['port'], $this->httpSetting['mode'], $this->httpSetting['type']); // Bind event callback diff --git a/src/Validator/HttpValidator.php b/src/Validator/HttpValidator.php index 9cfa6ca..2469036 100644 --- a/src/Validator/HttpValidator.php +++ b/src/Validator/HttpValidator.php @@ -58,6 +58,7 @@ private function validateField($request, array $matches, string $type, array $va if ($type === ValidatorFrom::GET) { if (! isset($get[$name])) { $request = $request->addQueryParam($name, $default); + $this->doValidation($name, $default, $info); continue; } $this->doValidation($name, $get[$name], $info); @@ -67,6 +68,7 @@ private function validateField($request, array $matches, string $type, array $va if ($type === ValidatorFrom::POST && \is_array($post)) { if (! isset($post[$name])) { $request = $request->addParserBody($name, $default); + $this->doValidation($name, $default, $info); continue; } $this->doValidation($name, $post[$name], $info);