format = $format; } public function execute(array $data) { if (isset($data[$this->field]) && $data[$this->field] !== '') { $date = \DateTime::createFromFormat($this->format, $data[$this->field]); if ($date !== false) { $errors = \DateTime::getLastErrors(); return $errors['error_count'] === 0 && $errors['warning_count'] === 0; } return false; } return true; } }