protected function init()
 {
     $this->setOption(array('required' => true, 'min_length' => 4, 'max_length' => 32));
     parent::init();
     $this->setPattern(self::REGEX_LOGIN);
     $this->setMessage('not_match', 'Invalid login');
 }
 public function isValid($value)
 {
     if (!preg_match("/^[a-z0-9~@+:\\[\\]\\.-]+\$/i", $value)) {
         $idna = new waIdna();
         $value = $idna->encode($value);
     }
     return parent::isValid($value);
 }
Example #3
0
 public function isValid($value)
 {
     parent::isValid($value);
     // more restrictions for common protocols
     if (!$this->isEmpty($value) && !$this->getErrors() && ('http' == substr($value, 0, 4) || 'ftp' == substr($value, 0, 3))) {
         if (!preg_match('`^(https?|ftp):((//)|(\\\\\\\\))+((?:([^[:punct:]]|-)+\\.)+[^[:punct:]]{2,6})((/|\\|#)([^[:punct:]]|[:#@%/;$()~_?\\+-=\\.&\\\\])*)?$`ui', $value)) {
             $this->setError($this->getMessage('not_match', array('value' => $value)));
         }
     }
     return !$this->getErrors();
 }