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

[5.5] Also validate DateTimeImmutable #20110

Merged
merged 1 commit into from
Jul 17, 2017
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
2 changes: 1 addition & 1 deletion src/Illuminate/Validation/Concerns/ValidatesAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ protected function validateConfirmed($attribute, $value)
*/
protected function validateDate($attribute, $value)
{
if ($value instanceof DateTime) {
if ($value instanceof DateTimeInterface) {
return true;
}

Expand Down
4 changes: 4 additions & 0 deletions tests/Validation/ValidationValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use DateTime;
use Mockery as m;
use DateTimeImmutable;
use Illuminate\Support\Arr;
use Illuminate\Support\Carbon;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -2274,6 +2275,9 @@ public function testValidateDateAndFormat()
$v = new Validator($trans, ['x' => new DateTime], ['x' => 'date']);
$this->assertTrue($v->passes());

$v = new Validator($trans, ['x' => new DateTimeImmutable], ['x' => 'date']);
$this->assertTrue($v->passes());

$v = new Validator($trans, ['x' => '2000-01-01'], ['x' => 'date_format:Y-m-d']);
$this->assertTrue($v->passes());

Expand Down