From d5870ddb59c2068c96c3a45965c749728fb1e086 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 6 Mar 2016 21:01:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BValidate=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Error.php | 2 +- library/think/Validate.php | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/library/think/Error.php b/library/think/Error.php index 6bf8d79c..ef5cf660 100644 --- a/library/think/Error.php +++ b/library/think/Error.php @@ -141,7 +141,7 @@ class Error */ public static function output($exception, array $vars) { - http_response_code($exception instanceof \think\Exception ? $exception->getHttpStatus() : 500); + http_response_code($exception instanceof Exception ? $exception->getHttpStatus() : 500); $type = Config::get('default_return_type'); diff --git a/library/think/Validate.php b/library/think/Validate.php index c5dfb830..89128f2f 100644 --- a/library/think/Validate.php +++ b/library/think/Validate.php @@ -337,8 +337,7 @@ class Validate */ public static function filter($value, $rule, $params = []) { - $result = filter_var($value, is_int($rule) ? $rule : filter_id($rule), $params); - return false === $result ? false : true; + return false !== filter_var($value, is_int($rule) ? $rule : filter_id($rule), $params); } /** @@ -464,7 +463,7 @@ class Validate } else { $name = $rules; } - $rules = $config[$name]; + $rules = isset($config[$name]) ? $config[$name] : []; if (isset($config['__all__'])) { $rules = array_merge($config['__all__'], $rules); }