Skip to content

Commit

Permalink
refactor: enforce string at datetime casting
Browse files Browse the repository at this point in the history
  • Loading branch information
DannyvdSluijs committed Nov 21, 2024
1 parent 185276f commit d9538d2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/JsonSchema/Constraints/FormatConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function check(&$element, $schema = null, ?JsonPointer $path = null, $i =

protected function validateDateTime($datetime, $format)
{
$dt = \DateTime::createFromFormat($format, $datetime);
$dt = \DateTime::createFromFormat($format, (string) $datetime);

if (!$dt) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion tests/Constraints/FormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function getInvalidFormats(): array
['1999-01-11T00:00:00+1:00', 'date-time'],
['1999.000Z-01-11T00:00:00+1:00', 'date-time'],

[(string) PHP_INT_MAX, 'utc-millisec'],
[PHP_INT_MAX, 'utc-millisec'],

['grey', 'color'],
['#HHH', 'color'],
Expand Down

0 comments on commit d9538d2

Please sign in to comment.