for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of Dimtrovich/Validation.
*
* (c) 2023 Dimitri Sitchet Tomkeu <[email protected]>
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Dimtrovich\Validation\Rules;
use Exception;
use Rakit\Validation\Rules\Traits\DateUtilsTrait;
class Before extends AbstractRule
{
use DateUtilsTrait;
* @var array
protected $fillableParams = ['time'];
* Check the value is valid
* @param mixed $value
* @throws Exception
public function check($value): bool
$this->requireParameters($this->fillableParams);
$time = $this->parameter('time');
if (! $this->isValidDate($value)) {
throw $this->throwException($value);
}
if (! $this->isValidDate($time)) {
$time = $this->getAttribute()->getValue($time);
throw $this->throwException($time);
return $this->getTimeStamp($time) > $this->getTimeStamp($value);