public isValidDate ( $value ) : boolean | ||
return | boolean | true if the given value matches with the date pattern. |
/** * Determine if the given value is of a particular type using RegExp. * @param string value to check * @return boolean true if value fits the type expression. */ protected function evaluateDataTypeCheck($value) { if ($value == '') { return true; } switch ($this->getDataType()) { case TValidationDataType::Integer: return preg_match('/^[-+]?[0-9]+$/', trim($value)); case TValidationDataType::Float: return preg_match('/^[-+]?([0-9]*\\.)?[0-9]+([eE][-+]?[0-9]+)?$/', trim($value)); case TValidationDataType::Date: $dateFormat = $this->getDateFormat(); if (strlen($dateFormat)) { $formatter = new TSimpleDateFormatter($dateFormat); return $formatter->isValidDate($value); } else { return strtotime($value) > 0; } } return true; }