PUT方法REST应用未通过验证(codeigniter)

时间:2019-03-12 00:03:03

标签: javascript rest codeigniter

我有这个PUT方法,它可以接收数据,并且如果参数不在数据库中或未发送,则可以正常工作。

function tickets_put($id = null) {
  $data = $this -> put();
  if ($id) {
    $ticketExists = $this -> DAO -> selectEntity('tickets', array("idTicket" => $id), TRUE);
    if ($ticketExists['data']) {
      //works fine until here, i guess
      $this -> form_validation -> set_data($data);

      $this -> form_validation -> set_rules('titleTicket', 'titleTicket', 'required|max_length[50]|min_length[5]');
      $this -> form_validation -> set_rules('descriptionTicket', 'descriptionTicket', 'required');
      $this -> form_validation -> set_rules('responsableTicket', 'responsableTicket', 'required|max_length[50]|min_length[10]');
      $this -> form_validation -> set_rules('asignedToTicket', 'asignedToTicket', 'required|max_length[50]|min_length[10]');
      $this -> form_validation -> set_rules('dueDateTicket', 'dueDateTicket', 'required');
      //skips the validations even if the correct data is sent
      if ($this -> form_validation -> run() == FALSE) {
        $response = array(
          "status" => "error",
          "status_code" => 409,
          "message" => "Validatins failed, see validations object for more details",
          //apparently everything works from here on "validations"=>$this->form_validation->error_array()
        );
      } else {
        $response = $this - > DAO - > updateData('Tickets', $this - > put(), array("idTicket" => $id));
      }
    } else {
      $response = array(
        "status" => "success",
        "status_code" => 200,
        "message" => "no esta en la bd",
        "data" => null);
    }
  } else {
    $response = array(
      "status" => "success",
      "status_code" => 200,
      "message" => "id no enviado",
      "data" => null);
  }
  $this  -> response($response, $response['status_code']);
}

我能从中得出的结论是,put方法的值未进入form_validation

它返回验证失败

0 个答案:

没有答案