Example #1
0
 public function normalize($input, $property, model_editor $editor)
 {
     if ($this->isReadOnly) {
         return null;
     }
     $input = parent::normalize($input, $property, $editor);
     if ($input !== null) {
         if ($this->collapseWhitespace) {
             $input = preg_replace('/\\s+/', ' ', $input);
         }
         if ($this->trim) {
             $input = trim($input);
         }
     }
     return $input;
 }
Example #2
0
 public function validate($value, $property, model_editor $editor)
 {
     parent::validate($value, $property, $editor);
     if ($value !== null) {
         $ts = $this->parseStorageToDatetime($value);
         if ($this->notBefore instanceof \DateTime && $ts < $this->notBefore) {
             throw new \InvalidArgumentException(_L('Selected date is out of range.'));
         }
         if ($this->notAfter instanceof \DateTime && $ts > $this->notAfter) {
             throw new \InvalidArgumentException(_L('Selected date is out of range.'));
         }
     }
     return true;
 }