From 78133b97abb50581d3c870f0d3b39410d8f20922 Mon Sep 17 00:00:00 2001 From: dmjohnsson23 Date: Thu, 3 Oct 2024 16:24:01 -0600 Subject: [PATCH] Fix bug when `Multiple` is passed an invalid value If you are using `Multiple` to validate, and pass a value that is unsupported by the `%` operator, it will fail instead of creating a validation error. This fixes that bug. --- library/Rules/Multiple.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/Rules/Multiple.php b/library/Rules/Multiple.php index 3c72834b5..722922ff2 100644 --- a/library/Rules/Multiple.php +++ b/library/Rules/Multiple.php @@ -9,6 +9,10 @@ namespace Respect\Validation\Rules; +use function filter_var; + +use const FILTER_VALIDATE_INT; + /** * @author Danilo Benevides * @author Henrique Moody @@ -31,6 +35,9 @@ public function __construct(int $multipleOf) */ public function validate($input): bool { + if (filter_var($input, FILTER_VALIDATE_INT) === false) { + return false; + } if ($this->multipleOf == 0) { return $input == 0; }