예제 #1
0
파일: Register.php 프로젝트: rcrrich/cunity
 /**
  * @return bool
  */
 private function validateForm()
 {
     $validateAlpha = new Zend_Validate_Alpha();
     $validateMail = new Email();
     $validateUsername = new Zend_Validate();
     $validatePassword = new Password();
     $validateUsername->addValidator(new Zend_Validate_StringLength(["max" => 20, "min" => 2]), true)->addValidator(new \Zend_Validate_Alnum());
     if (!$validateUsername->isValid($_POST['username'])) {
         $this->errors["username"] = "******";
     }
     if (!$validateMail->isValid($_POST['email'])) {
         $this->errors["email"] = implode(',', $validateMail->getMessages());
     }
     if (!$validatePassword->passwordValid($_POST['password'], $_POST['password-repeat'])) {
         $this->errors["password"] = implode(',', $validatePassword->getMessages());
         $this->errors["password_repeat"] = "";
     }
     if (!isset($_POST['sex']) || $_POST['sex'] != 'm' && $_POST['sex'] != "f") {
         $this->errors["sex"] = "Please select a gender";
     }
     if (!$validateAlpha->isValid($_POST['firstname'])) {
         $this->errors["firstname"] = "The Firstname is invalid";
     }
     if (!$validateAlpha->isValid($_POST['lastname'])) {
         $this->errors["lastname"] = "The Lastname is invalid";
     }
     return empty($this->errors);
 }
예제 #2
0
파일: Register.php 프로젝트: rcrrich/cunity
 /**
  * @return bool
  * @throws \Exception
  */
 public function validateForm()
 {
     $validateMail = new Email();
     $validateUsername = new Username();
     $validatePassword = new Password();
     if (Cunity::get("settings")->getSetting("register.min_age")) {
         $validateBirthday = new Zend_Validate_Date(["format" => "mm/dd/yyyy"]);
         if (!$validateBirthday->isValid($_POST['birthday'])) {
             $this->errors['birthday'] = implode(',', $validateBirthday->getMessages());
         }
     }
     if (!$validateUsername->isValid($_POST['username'])) {
         $this->errors["username"] = implode(',', $validateUsername->getMessages());
     }
     if (!$validateMail->isValid($_POST['email'])) {
         $this->errors["email"] = implode(',', $validateMail->getMessages());
     }
     if (!$validatePassword->passwordValid($_POST['password'], $_POST['password_repeat'])) {
         $this->errors["password"] = implode(',', $validatePassword->getMessages());
         $this->errors["password_repeat"] = "";
     }
     return empty($this->errors);
 }