Skip to content

Commit 9fc0165

Browse files
dmjohnsson23henriquemoody
authored andcommitted
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.
1 parent 967f7b6 commit 9fc0165

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

library/Rules/Multiple.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
namespace Respect\Validation\Rules;
1111

12+
use function filter_var;
13+
14+
use const FILTER_VALIDATE_INT;
15+
1216
/**
1317
* @author Danilo Benevides <[email protected]>
1418
* @author Henrique Moody <[email protected]>
@@ -31,6 +35,9 @@ public function __construct(int $multipleOf)
3135
*/
3236
public function validate($input): bool
3337
{
38+
if (filter_var($input, FILTER_VALIDATE_INT) === false) {
39+
return false;
40+
}
3441
if ($this->multipleOf == 0) {
3542
return $input == 0;
3643
}

0 commit comments

Comments
 (0)