Jyxo\Input\Validator\IsDate::isValid PHP Method

isValid() public method

Validates a value.
public isValid ( mixed $value ) : boolean
$value mixed Input value
return boolean
    public function isValid($value) : bool
    {
        $value = (string) $value;
        // Form check
        if (!preg_match('~^(\\d{4})-(\\d{2})-(\\d{2})$~', $value, $matches)) {
            return false;
        }
        list(, $year, $month, $day) = $matches;
        // Date validity check
        if (!checkdate((int) $month, (int) $day, (int) $year)) {
            return false;
        }
        return true;
    }
IsDate