Commit e527f0bb28d40cdae66157cd3683ecb3d380d33c
1 parent
1fadd3cf
Date format validation attempts to force the user to enter a date in the correct…
… format on a field where the user did not enter a date on a non-Required field. Jira:KTS-4434 Committed by: Charl Joseph Mert Reviewed by: Megan Watson
Showing
1 changed file
with
8 additions
and
13 deletions
plugins/ktcore/KTValidators.php
| ... | ... | @@ -588,24 +588,19 @@ class KTDateValidator extends KTValidator { |
| 588 | 588 | function validate($data) { |
| 589 | 589 | $results = array(); |
| 590 | 590 | $errors = array(); |
| 591 | - | |
| 592 | - // very simple if we're required and not present, fail | |
| 593 | - // otherwise, its ok. | |
| 594 | - $pMetaKey = array_keys($data); | |
| 595 | - $fieldId = str_replace('metadata_', '', $pMetaKey); | |
| 596 | - $oField = new DocumentField(); | |
| 597 | - $oField->load($fieldId); | |
| 598 | - | |
| 599 | - if (!$oField->getIsMandatory()) { | |
| 600 | - return; | |
| 601 | - } | |
| 602 | - | |
| 591 | + | |
| 603 | 592 | $val = KTUtil::arrayGet($data, $this->sInputVariable); |
| 604 | - | |
| 593 | + | |
| 605 | 594 | if ($this->bTrim) { |
| 606 | 595 | $val = trim($val); |
| 607 | 596 | } |
| 608 | 597 | |
| 598 | + // very simple if we're required and not present, fail | |
| 599 | + // otherwise, its ok. | |
| 600 | + if (empty($val) || $val == '') { | |
| 601 | + return; | |
| 602 | + } | |
| 603 | + | |
| 609 | 604 | if (preg_match ("/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/", $val, $parts)) |
| 610 | 605 | { |
| 611 | 606 | //check weather the date is valid of not | ... | ... |