Esempio n. 1
0
 /**
  * {@inheritDoc}
  */
 public function validate()
 {
     $value = $this->val();
     if (!empty($value) && !filter_var($value, FILTER_VALIDATE_URL)) {
         $this->error(static::$error_message);
         return false;
     }
     return parent::validate();
 }
Esempio n. 2
0
 /**
  * {@inheritDoc}
  */
 public function validate()
 {
     $value = $this->val();
     if (isset(self::$uploadErrors[$value['error']])) {
         $this->error(self::$uploadErrors[$value['error']]);
         return false;
     }
     return parent::validate();
 }
Esempio n. 3
0
 /**
  * {@inheritDoc}
  */
 public function validate()
 {
     $value = $this->val();
     if (!empty($value) && !preg_match('/^#[A-Fa-f0-9]{6}$/', $value)) {
         $this->error(static::$error_message);
         return false;
     }
     return parent::validate();
 }
Esempio n. 4
0
 /**
  * {@inheritDoc}
  */
 public function validate()
 {
     $value = $this->val();
     if ($value) {
         if (!($date = date_create($value))) {
             $this->error(static::$error_message);
             return false;
         }
         $this->val($date->format(static::$format));
     }
     return parent::validate();
 }
Esempio n. 5
0
 /**
  * {@inheritDoc}
  */
 public function validate()
 {
     $value = $this->val();
     if (!empty($value) && !$this->allowNewValues) {
         if ($this->attr('multiple') && is_array($value)) {
             foreach ($value as $val) {
                 if (!isset($this->options[$val])) {
                     $this->error(static::$error_message);
                     return false;
                 }
             }
         } elseif (!isset($this->options[$value])) {
             $this->error(static::$error_message);
             return false;
         }
     }
     return parent::validate();
 }