コード例 #1
0
 /**
  * @param mixed $value
  * @return bool
  */
 public function isValid($value)
 {
     $this->setValue($value);
     $result = true;
     if ($this->passwordOptions->isContainsNumber() && preg_match('/[0-9]/', $value) !== 1) {
         $this->error(self::ERROR_NO_NUMBER);
         $result = false;
     }
     if ($this->passwordOptions->isContainsLowerLetter() && preg_match('/[a-z]/', $value) !== 1) {
         $this->error(self::ERROR_NO_LOWER_CASE_LETTER);
         $result = false;
     }
     if ($this->passwordOptions->isContainsUpperLetter() && preg_match('/[A-Z]/', $value) !== 1) {
         $this->error(self::ERROR_NO_UPPER_CASE_LETTER);
         $result = false;
     }
     if ($this->passwordOptions->isContainsSpecialChar() && preg_match('/[\'\\/~`\\!@#\\$%\\^&\\*\\(\\)_\\-\\+=\\{\\}\\[\\]\\|;:"\\<\\>,\\.\\?\\\\]/', $value) !== 1) {
         $this->error(self::ERROR_NO_SPECIAL_CHAR);
         $result = false;
     }
     return $result;
 }