Skip to content

Commit 86fa403

Browse files
author
Michael Chiocca
committed
Add support for draft-04 multipleOf.
1 parent 522f0ae commit 86fa403

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/JsonSchema/Constraints/Number.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,16 @@ public function check($element, $schema = null, $path = null, $i = null)
5252
$this->addError($path, "must have a maximum value of " . $schema->maximum);
5353
}
5454

55-
// Verify divisibleBy
55+
// Verify divisibleBy - Draft v3
5656
if (isset($schema->divisibleBy) && $this->fmod($element, $schema->divisibleBy) != 0) {
5757
$this->addError($path, "is not divisible by " . $schema->divisibleBy);
5858
}
5959

60+
// Verify multipleOf - Draft v4
61+
if (isset($schema->multipleOf) && $this->fmod($element, $schema->multipleOf) != 0) {
62+
$this->addError($path, "must be a multiple of " . $schema->multipleOf);
63+
}
64+
6065
$this->checkFormat($element, $schema, $path, $i);
6166
}
6267

src/JsonSchema/Constraints/Undefined.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,12 @@ protected function validateCommonProperties($value, $schema = null, $path = null
143143
if (is_object($value)) {
144144
if (isset($schema->minProperties)) {
145145
if (count(get_object_vars($value)) < $schema->minProperties) {
146-
$this->addError($path, "must contain a minimum of " + $schema->minProperties + " properties");
146+
$this->addError($path, "must contain a minimum of " . $schema->minProperties . " properties");
147147
}
148148
}
149149
if (isset($schema->maxProperties)) {
150150
if (count(get_object_vars($value)) > $schema->maxProperties) {
151-
$this->addError($path, "must contain no more than " + $schema->maxProperties + " properties");
151+
$this->addError($path, "must contain no more than " . $schema->maxProperties . " properties");
152152
}
153153
}
154154
}

tests/JsonSchema/Tests/Drafts/Draft4Test.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ protected function getSkippedTests()
1919
'allOf.json',
2020
'anyOf.json',
2121
'definitions.json',
22-
'multipleOf.json',
2322
'not.json',
2423
'oneOf.json',
2524
// Partially Implemented

0 commit comments

Comments
 (0)