$params]; } return $params; } /** * Set date format * @param string $format * @return bool */ protected function setFormat($format): bool { if (empty($format) || ! is_string($format)) { return false; } $this->format = $this->replace['format'] = $format; return true; } /** * Set date format * @param string $format * @return static */ public function format($format) { $this->setFormat($format); return $this; } public function check(&$value) { if ($value instanceof DateTimeInterface) { return true; } if (strtotime($value) === false) { return false; } return date_create_from_format('!' . $this->format, $value) !== false; } /** * Default message * @return string */ public function defaultMessage(): string { return _t('error', "The [attribute] is not valid date format, '[format]' required"); } }