Пример #1
0
 public function validate($object, $field_name)
 {
     if (!parent::validate($object, $field_name)) {
         return FALSE;
     }
     $value = $object->{$field_name};
     if (empty($value)) {
         return TRUE;
     }
     if (strlen($value) > $this->size) {
         $this->setError('wrong_value', 'Field "' . $this->getLabel() . '" (' . $field_name . ') content is too long ' . strlen($value) . ' characters, only ' . $this->size . ' allowed!');
         return FALSE;
     }
     return TRUE;
 }
Пример #2
0
 public function validate($object, $field_name)
 {
     if (!parent::validate($object, $field_name)) {
         return FALSE;
     }
     $value = $object->{$field_name};
     if (empty($value)) {
         return TRUE;
     }
     if (empty($this->enumeration[$value])) {
         $this->setError('wrong_value', 'Field "' . $this->getLabel() . '" (' . $field_name . ') should contains one of this options: ' . join('/', array_keys($this->enumeration)));
         return FALSE;
     }
     return TRUE;
 }