Skip to content

Commit

Permalink
Revert "[10.x] fix Before/After validation rules (#49871)"
Browse files Browse the repository at this point in the history
This reverts commit cc653b0.
  • Loading branch information
taylorotwell authored Feb 8, 2024
1 parent 9448e01 commit e874cb9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
8 changes: 1 addition & 7 deletions src/Illuminate/Validation/Concerns/ValidatesAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,7 @@ protected function compareDates($attribute, $value, $parameters, $operator)
}

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

if (! is_string($comparedValue) && ! is_numeric($comparedValue) && ! $comparedValue instanceof DateTimeInterface) {
return false;
}

$date = $this->getDateTimestamp($comparedValue);
$date = $this->getDateTimestamp($this->getValue($parameters[0]));
}

return $this->compare($this->getDateTimestamp($value), $date, $operator);
Expand Down
6 changes: 0 additions & 6 deletions tests/Validation/ValidationValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5980,12 +5980,6 @@ public function testBeforeAndAfter()

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

$v = new Validator($trans, ['x' => ['a' => ['v' => 'c']], 'y' => 'invalid'], ['x' => 'date', 'y' => 'date|after:x']);
$this->assertTrue($v->fails());

$v = new Validator($trans, ['x' => ['a' => ['v' => 'c']], 'y' => 'invalid'], ['x' => 'date', 'y' => 'date|before:x']);
$this->assertTrue($v->fails());
}

public function testBeforeAndAfterWithFormat()
Expand Down

0 comments on commit e874cb9

Please sign in to comment.