Exemplo n.º 1
0
 /**
  * The given $value is valid if it is an array of format array(hash:string, phrase:string) and the hash was derived from the entered phrase
  * 
  * @param mixed $value The value that should be validated
  * @return void
  */
 protected function isValid($value)
 {
     if (!($this->options["ignoreWhenLoggedIn"] && $this->securityContext->getAccount())) {
         if (is_array($value)) {
             if (empty($value["hash"]) || empty($value["phrase"])) {
                 $this->addError("Malformed array given; expected array(hash:string, phrase:string)", 422526241);
             } else {
                 if ($this->captchaService->validatePhrase($value["phrase"], $value["hash"]) !== true) {
                     $this->addError("Given captcha phrase mismatches the hash", 422526242);
                 }
             }
         } else {
             $this->addError("This argument must be an array", 422526240);
         }
     }
 }