示例#1
0
 protected function fileValidateOne()
 {
     setContentType("json");
     $file = new File();
     $given = array_keys($_POST);
     $response["error"] = null;
     if (count($given) == 1) {
         if ($given[0] == "description") {
             $file->setDescription($_POST["description"]);
         }
         if (!$file->validate()) {
             foreach ($file->getValidationFailures() as $failure) {
                 if ($given[0] == $failure->getPropertyPath()) {
                     $response["error"] = array("name" => $failure->getPropertyPath(), "message" => $failure->getMessage());
                 }
             }
         }
         $this->viewString(json_encode($response));
     }
 }