Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interchange Maximum/Minimum exclusive messages #126

Merged
merged 1 commit into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Schema/Keywords/Maximum.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,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 @@ -48,15 +48,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 @@ -41,6 +41,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 @@ -41,6 +41,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());
}
}
}