{"size": 937, "ext": "js", "max_stars_repo_path": "app/validations/category.js", "max_stars_repo_name": "UDINUS-K3/backend_sip", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/validations/category.js", "max_issues_repo_name": "UDINUS-K3/backend_sip", "max_issues_repo_issues_event_min_datetime": "2022-01-22T11:31:29.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-22T11:31:29.000Z", "max_forks_repo_path": "app/validations/category.js", "max_forks_repo_name": "UDINUS-K3/backend_sip", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 18.74, "max_line_length": 69, "alphanum_fraction": 0.560298826}
const { body, param, checkIf } = require("express-validator");

const save = () => {
  return [body("name").exists().not().isEmpty().isString().escape()];
};

const update = () => {
  return [
    param("id")
      .exists()
      .isUUID(4)
      .withMessage("Please provide a valid category id"),
    body("name").optional().isString().escape(),
  ];
};

const destroy = () => {
  return [
    param("id")
      .exists()
      .isUUID(4)
      .withMessage("Please provide a valid category id"),
  ];
};

const findById = () => {
  return [
    param("id")
      .exists()
      .isUUID(4)
      .withMessage("Please provide a valid category id"),
  ];
};

const findByAll = () => {
  return [
    param("name").optional().isString().escape(),
    param("page").optional().isNumeric().toInt(),
    param("per_page").optional().isNumeric().toInt(),
  ];
};

module.exports = {
  save,
  update,
  destroy,
  findById,
  findByAll,
};
