/**
  * @param string $value
  * @param array $allValuesContext
  * @return \DateTime|null
  */
 private function getValidDateTime($value, array $allValuesContext)
 {
     $validator = new DateTimeValidator();
     if (!$validator->validate($value, $allValuesContext)) {
         return null;
     }
     return $validator->getDate();
 }
 /**
  * Executes the real validation so it can be reused.
  * 
  * @param mixed $value The value to validate.
  * @return boolean Whether the value pass the validation.
  */
 protected function doValidate($value)
 {
     // ignore empty values
     if ($this->isEmpty($value)) {
         return true;
     }
     $isDate = new DateTimeValidator();
     if (!$isDate->validate($value)) {
         return false;
     }
     if (is_string($value)) {
         $value = new \DateTime($value);
     }
     return $value <= $this->date;
 }
 /**
  * Executes the real validation so it can be reused.
  * @param mixed $value The value to validate.
  * @return boolean Whether the value pass the validation.
  */
 protected function doValidate($value)
 {
     //ignore empty values
     if ($this->isEmpty($value)) {
         return true;
     }
     // Validate the given value as a valid date.
     $v = new DateTimeValidator();
     if (!$v->validate($value)) {
         return false;
     }
     $givenDate = $value;
     if (!$givenDate instanceof \DateTime) {
         $givenDate = new \DateTime($value);
     }
     $ageDate = new \DateTime(date(DATE_ISO8601, strtotime('-' . $this->minAge . ' years')));
     return $givenDate <= $ageDate;
 }
 $__filter = new TrimFilter(array('valueName' => 'when_added'));
 $__filter->filter($db, $row);
 $__filter = new TrimFilter(array('valueName' => 'acct_type_id'));
 $__filter->filter($db, $row);
 $__filter = new IntFilter(array('valueName' => 'acct_type_id'));
 $__filter->filter($db, $row);
 $__filter = new TrimFilter(array('valueName' => 'description'));
 $__filter->filter($db, $row);
 $__filter = new TrimFilter(array('valueName' => 'acct_no'));
 $__filter->filter($db, $row);
 $__filter = new TrimFilter(array('valueName' => 'ticker_symbol'));
 $__filter->filter($db, $row);
 unset($__filter);
 if (!isset($result->fieldErrors['when_added'])) {
     $__validator = new DateTimeValidator(array('valueName' => 'when_added'));
     $__validatorError = $__validator->validate($db, $row);
     if ($__validatorError != '') {
         $result->fieldErrors['when_added'] = $__validatorError;
     }
 }
 if (!isset($result->fieldErrors['description'])) {
     $__validator = new LengthValidator(array('maxLength' => 40, 'valueName' => 'description'));
     $__validatorError = $__validator->validate($db, $row);
     if ($__validatorError != '') {
         $result->fieldErrors['description'] = $__validatorError;
     }
 }
 if (!isset($result->fieldErrors['acct_no'])) {
     $__validator = new LengthValidator(array('maxLength' => 32, 'valueName' => 'acct_no'));
     $__validatorError = $__validator->validate($db, $row);
     if ($__validatorError != '') {
 public function testValidateEmptyValue()
 {
     $v = new DateTimeValidator();
     $this->assertTrue($v->validate(''));
     $this->assertTrue($v->validate(null));
 }