Esempio n. 1
0
 protected function commentValidateOne()
 {
     setContentType("json");
     $comment = new Comment();
     $given = array_keys($_POST);
     $response["error"] = null;
     if (count($given) == 1) {
         if ($given[0] == "text") {
             $comment->setText($_POST["text"]);
         }
         if (!$comment->validate()) {
             foreach ($comment->getValidationFailures() as $failure) {
                 if ($given[0] == $failure->getPropertyPath()) {
                     $response["error"] = array("name" => $failure->getPropertyPath(), "message" => $failure->getMessage());
                 }
             }
         }
         $this->viewString(json_encode($response));
     }
 }