Example #1
0
 public function validate()
 {
     list($continue, $errors) = parent::validate();
     if (!$continue) {
         return array(false, $errors);
     }
     // if empty
     if (empty($this->value)) {
         return array(true, $errors);
     }
     // validating email address
     if (filter_var($this->value, FILTER_VALIDATE_EMAIL) === false) {
         $errors[] = 'Wartość pola "' . $this->label . '" nie jest poprawnym adresem email';
     }
     return array(true, $errors);
 }
Example #2
0
 public function validate()
 {
     list($continue, $errors) = parent::validate();
     if (!$continue) {
         return array(false, $errors);
     }
     // if empty
     if (empty($this->value)) {
         return array(true, $errors);
     }
     // adding 'http://' if missing
     if (substr($this->value, 0, 7) != 'http://' && substr($this->value, 0, 8) != 'https://') {
         $this->value = 'http://' . $this->value;
     }
     // validating URL address
     if (filter_var($this->value, FILTER_VALIDATE_URL) === false) {
         $errors[] = 'Wartość pola "' . $this->label . '" nie jest poprawnym adresem URL';
     }
     return array(true, $errors);
 }