Skip to content

Commit 9994241

Browse files
committed
fix(NumberConstraint): force positive value on first arg
Resolves #315 - `multipleOf` is inconsistent, fails for negative numbers
1 parent 0bbaac8 commit 9994241

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ coverage
77
.settings
88
composer.lock
99
docs-api
10+
phpunit.xml

src/JsonSchema/Constraints/NumberConstraint.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public function check($element, $schema = null, JsonPointer $path = null, $i = n
6969

7070
private function fmod($number1, $number2)
7171
{
72+
$number1 = abs($number1);
7273
$modulus = fmod($number1, $number2);
7374
$precision = abs(0.0000000001);
7475
$diff = (float)($modulus - $number2);

0 commit comments

Comments
 (0)