Skip to content

Commit

Permalink
Fixing issue where 0 is discarded as a valid timestamp (#46158)
Browse files Browse the repository at this point in the history
  • Loading branch information
rojtjo committed Feb 17, 2023
1 parent 803e529 commit 15f419f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Validation/Concerns/ValidatesAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ protected function compareDates($attribute, $value, $parameters, $operator)
return $this->checkDateTimeOrder($format, $value, $parameters[0], $operator);
}

if (! $date = $this->getDateTimestamp($parameters[0])) {
if (is_null($date = $this->getDateTimestamp($parameters[0]))) {
$date = $this->getDateTimestamp($this->getValue($parameters[0]));
}

Expand Down
6 changes: 6 additions & 0 deletions tests/Validation/ValidationValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5028,6 +5028,12 @@ public function testBeforeAndAfter()

$v = new Validator($trans, ['x' => '17:44'], ['x' => 'After:17:44:00']);
$this->assertTrue($v->fails());

$v = new Validator($trans, ['x' => '0001-01-01T00:00'], ['x' => 'before:1970-01-01']);
$this->assertTrue($v->passes());

$v = new Validator($trans, ['x' => '0001-01-01T00:00'], ['x' => 'after:1970-01-01']);
$this->assertTrue($v->fails());
}

public function testBeforeAndAfterWithFormat()
Expand Down

0 comments on commit 15f419f

Please sign in to comment.