We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e913512 commit 9877134Copy full SHA for 9877134
src/Schema/Type/Number.php
@@ -50,7 +50,9 @@ public function validate(mixed $value, callable $fail): void
50
}
51
52
53
- if ($this->multipleOf !== null && $value % $this->multipleOf !== 0) {
+ // Divide the value by multipleOf instead of using the modulo operator to avoid bugs when using a multipleOf
54
+ // that has decimal places. (Since the modulo operator converts the multipleOf to int)
55
+ if ($this->multipleOf !== null && $value/$this->multipleOf !== (float) round($value/$this->multipleOf)) {
56
$fail(sprintf('must be a multiple of %d', $this->multipleOf));
57
58
0 commit comments