Increase CanValidateDateTimeTest invalid data test coverage #1460
+4
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
Why?
This change is to ensure
Respect\Validation
is intentional about the DateTime formats.For context the ISO 8601 standard says that we shouldn't accept
-00:00
(or anything similar) offsets.I noticed that there was an a change in how
CanValidateDateTime.php
behaved from v2.2 to v2.3.Prior to v2.3 date time formats of
2018-01-30T19:04:35-00:00
(note the -00:00) would pass validation. After updating to v2.3 the format is not accepted.This is because the
DateTime::createFromFormat
accepts the$value
of2018-01-30T19:04:35-00:00
but internally converts the-00:00
to+00:00
This in turn causes the validation around
$value !== $formattedDate->format($format))
to failFollow up
Since PHP internally converts the
-00:00
to a+00:00
, will Respect\Validation ever consider accepting a format of-00:00
(and other offshoots of the-0000
time offsets) 😄 ?