Skip to content

Commit 15f419f

Browse files
authored
Fixing issue where 0 is discarded as a valid timestamp (#46158)
1 parent 803e529 commit 15f419f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Illuminate/Validation/Concerns/ValidatesAttributes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ protected function compareDates($attribute, $value, $parameters, $operator)
249249
return $this->checkDateTimeOrder($format, $value, $parameters[0], $operator);
250250
}
251251

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

tests/Validation/ValidationValidatorTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5028,6 +5028,12 @@ public function testBeforeAndAfter()
50285028

50295029
$v = new Validator($trans, ['x' => '17:44'], ['x' => 'After:17:44:00']);
50305030
$this->assertTrue($v->fails());
5031+
5032+
$v = new Validator($trans, ['x' => '0001-01-01T00:00'], ['x' => 'before:1970-01-01']);
5033+
$this->assertTrue($v->passes());
5034+
5035+
$v = new Validator($trans, ['x' => '0001-01-01T00:00'], ['x' => 'after:1970-01-01']);
5036+
$this->assertTrue($v->fails());
50315037
}
50325038

50335039
public function testBeforeAndAfterWithFormat()

0 commit comments

Comments
 (0)