diff --git a/src/app/resource/controllers/ResController.php b/src/app/resource/controllers/ResController.php index 30ac5bb4cb7b1ffc5c21d8d456c9c61ddb388d29..aa6ed19a2dd8c2e266191febbc673fde97583b73 100755 --- a/src/app/resource/controllers/ResController.php +++ b/src/app/resource/controllers/ResController.php @@ -66,13 +66,18 @@ class ResController $data = $request->getParams(); - $check = Validator::notEmpty()->validate($data['encodedFile']); - $check = $check && Validator::stringType()->notEmpty()->validate($data['format']); - $check = $check && Validator::stringType()->notEmpty()->validate($data['status']); - $check = $check && Validator::intVal()->notEmpty()->validate($data['type_id']); - $check = $check && Validator::stringType()->notEmpty()->validate($data['category_id']); - if (!$check) { - return $response->withStatus(400)->withJson(['errors' => 'Bad Request']); + if (empty($data)) { + return $response->withStatus(400)->withJson(['errors' => 'Data is not set or empty']); + } elseif (!Validator::notEmpty()->validate($data['encodedFile'])) { + return $response->withStatus(400)->withJson(['errors' => 'Data[encodedFile] is empty']); + } elseif (!Validator::stringType()->notEmpty()->validate($data['format'])) { + return $response->withStatus(400)->withJson(['errors' => 'Data[format] is empty or not a string']); + } elseif (!Validator::stringType()->notEmpty()->validate($data['status'])) { + return $response->withStatus(400)->withJson(['errors' => 'Data[status] is empty or not a string']); + } elseif (!Validator::intVal()->notEmpty()->validate($data['type_id'])) { + return $response->withStatus(400)->withJson(['errors' => 'Data[type_id] is empty or not an integer']); + } elseif (!Validator::stringType()->notEmpty()->validate($data['category_id'])) { + return $response->withStatus(400)->withJson(['errors' => 'Data[category_id] is empty or not a string']); } $resId = StoreController::storeResource($data);