Skip to content

Commit

Permalink
resolve #125
Browse files Browse the repository at this point in the history
  • Loading branch information
sidux authored and scaytrase committed May 12, 2021
1 parent 2d78ee9 commit 580ebf2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Schema/Keywords/Maximum.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ public function validate($data, $maximum, bool $exclusiveMaximum = false): void
throw KeywordMismatch::fromKeyword(
'maximum',
$data,
sprintf('Value %d must be less or equal to %d', $data, $maximum)
sprintf('Value %d must be less than %d', $data, $maximum)
);
}

if (! $exclusiveMaximum && $data > $maximum) {
throw KeywordMismatch::fromKeyword(
'maximum',
$data,
sprintf('Value %d must be less than %d', $data, $maximum)
sprintf('Value %d must be less or equal to %d', $data, $maximum)
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Schema/Keywords/Minimum.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ public function validate($data, $minimum, bool $exclusiveMinimum = false): void
throw KeywordMismatch::fromKeyword(
'minimum',
$data,
sprintf('Value %d must be greater or equal to %d', $data, $minimum)
sprintf('Value %d must be greater than %d', $data, $minimum)
);
}

if (! $exclusiveMinimum && $data < $minimum) {
throw KeywordMismatch::fromKeyword(
'minimum',
$data,
sprintf('Value %d must be greater than %d', $data, $minimum)
sprintf('Value %d must be greater or equal to %d', $data, $minimum)
);
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/Schema/Keywords/MaximumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function testMaximumExclusiveKeywordGreen(): void
(new SchemaValidator())->validate($data, $schema);
} catch (KeywordMismatch $e) {
$this->assertEquals('maximum', $e->keyword());
$this->assertEquals('Keyword validation failed: Value 100 must be less than 100', $e->getMessage());
}
}
}
1 change: 1 addition & 0 deletions tests/Schema/Keywords/MinimumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function testMinimumExclusiveKeywordGreen(): void
(new SchemaValidator())->validate($data, $schema);
} catch (KeywordMismatch $e) {
$this->assertEquals('minimum', $e->keyword());
$this->assertEquals('Keyword validation failed: Value 100 must be greater than 100', $e->getMessage());
}
}
}

0 comments on commit 580ebf2

Please sign in to comment.