From 988f78b8e092d7fa7fb05e468f90b975ba6834f4 Mon Sep 17 00:00:00 2001 From: xl Date: Thu, 9 Nov 2023 22:15:45 +0800 Subject: [PATCH] eee --- src/Validator/Inject/Phone.php | 3 +++ src/Validator/Inject/Round.php | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Validator/Inject/Phone.php b/src/Validator/Inject/Phone.php index e70e85d..9e45168 100644 --- a/src/Validator/Inject/Phone.php +++ b/src/Validator/Inject/Phone.php @@ -18,6 +18,9 @@ class Phone implements ValidatorInterface */ public function dispatch(mixed $data, object $class): bool { + if ($data == null || !is_numeric($data)) { + return false; + } return preg_match(self::REG, $data); } } diff --git a/src/Validator/Inject/Round.php b/src/Validator/Inject/Round.php index efe9094..1a4134d 100644 --- a/src/Validator/Inject/Round.php +++ b/src/Validator/Inject/Round.php @@ -25,6 +25,9 @@ class Round implements ValidatorInterface */ public function dispatch(mixed $data, object $class): bool { - return round($data, $this->value) === $data; + if ($data === null) { + return false; + } + return round((float)$data, $this->value) === $data; } }