[5.4+] Fixed Validator failing on 'before_or_equal:today' for today's date #20868
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.
[ This is a follow-up for the prematurely closed PR #20789 . ]
Fixed Validator failing on 'before_or_equal:today' when the input is today's date and a format is specified
The issue was that the time part was bleeding through from the current timestamp in
DateTime::createFromFormat
.Test case:
Some further information I found (thanks to @arjasco 's comment on the previous PR):
!
prepended.@taylorotwell "Isn't this going to break applications? What if people want the time part?"
If you have time fields in the date format, the validation will still use them.
http://php.net/manual/en/datetime.createfromformat.php
I have also added a number of date validation tests in a second commit. These tests deal with the time parts, and show that the fix I made is not breaking anything.
If you still think this change might cause issues, please provide a test case that this PR causes to fail, so that I have a chance of fixing the problem.
The same changes can probably be applied to v5.5 to fix the bug there too, especially with the new
date_equals
validator which will probably suffer from this issue quite badly.