Skip to content

Commit

Permalink
Allow empty isDate, :required should be used to prevent blank field.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Lückers committed Apr 19, 2018
1 parent ec9d110 commit dc8a181
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions core/components/formit/src/FormIt/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,11 +619,13 @@ public function isNumber($key,$value) {
* @return boolean
*/
public function isDate($key,$value,$format = '%m/%d/%Y') {
$ts = false;
if (!empty($value)) {
$ts = strtotime($value);
}
if ($ts === false || empty($value)) {
/* allow empty isDate, :required should be used to prevent blank field */
if (empty($value)) {
return true;
}

$ts = strtotime($value);
if ($ts === false) {
return $this->_getErrorMessage($key,'vTextIsDate','formit.not_date',array(
'format' => $format,
'field' => $key,
Expand Down

0 comments on commit dc8a181

Please sign in to comment.