fix: validate empty date values #557

This commit is contained in:
vnmedeiros 2021-06-07 11:09:27 -03:00
parent 3a3986ba90
commit 3db120a8c3
1 changed files with 6 additions and 4 deletions

View File

@ -34,10 +34,12 @@ class Date extends Metadata_Type {
if (is_array($value)) { if (is_array($value)) {
foreach ($value as $date_value) { foreach ($value as $date_value) {
$d = \DateTime::createFromFormat($format, $date_value); if(!empty($date_value)) {
if (!$d || $d->format($format) !== $date_value) { $d = \DateTime::createFromFormat($format, $date_value);
$this->add_error($this->format_error_msg($date_value)); if (!$d || $d->format($format) !== $date_value) {
return false; $this->add_error($this->format_error_msg($date_value));
return false;
}
} }
} }
return true; return true;