{"action":"created","comment":{"url":"https://api.github.com/repos/justega247/Book-a-meal/pulls/comments/186039558","pull_request_review_id":117551915,"id":186039558,"diff_hunk":"@@ -0,0 +1,98 @@\n+import validator from 'validator';\n+import meals from '../seedData/meals'\n+\n+/**\n+ * @class Validate Meal\n+ */\n+class ValidateMeal {\n+  /**\n+   * validate meal input on creation\n+   *\n+   * @param {object} req\n+   * @param {object} res\n+   * @param {func} next\n+   *\n+   * @return {void}\n+   */\n+  static mealData(req, res, next) {\n+    if (!req.body.name || req.body.name.trim() === '') {\n+      return res.status(400)\n+        .json({\n+          message: 'Sorry,it seems your meal name is empty'\n+        });\n+    }\n+\n+    if (req.body.category.trim() === '') {\n+      return res.status(400)\n+        .json({\n+          message: 'Sorry, meal category cannot be empty'\n+        });\n+    }\n+\n+    if (!req.body.price) {\n+      return res.status(400)\n+        .json({\n+          message: 'Please, you need to specify a price'\n+        });\n+    }\n+\n+    if (req.body.name.trim().match(/[\\w\\s]+/) === false) {\n+      return res.status(400)\n+        .json({\n+          message: 'Sorry, that meal name is not valid'\n+        });\n+    }\n+\n+    if (!Number.isInteger(req.body.price)) {\n+      return res.status(400)\n+        .json({\n+          message: 'Sorry, your price value can only be an integer'\n+        });\n+    }\n+\n+    if (!validator.isAlpha(req.body.category)) {\n+      return res.status(400)\n+        .json({\n+          message: 'Sorry, the category you have entered in is invalid'\n+        });\n+    }\n+    next();\n+  }\n+\n+  /**\n+   * validate meal input on update\n+   *\n+   * @param {object} req\n+   * @param {object} res\n+   * @param {func} next\n+   *\n+   * @return {void}\n+   */\n+  static mealUpdateData(req, res, next) {\n+    if(req.body.category && req.body.category.trim() === '') {\n+      return res.status(400)\n+        .json({\n+          message: 'Sorry, you have to specify a proper category'\n+        });\n+    }\n+\n+    if(req.body.price) {\n+      if(!Number.isInteger(req.body.price)) {\n+        return res.status(400)\n+          .json({\n+            message: 'Sorry, you cannot update the price field with that value'\n+          })","path":"server/middleware/validateMeal.js","position":84,"original_position":84,"commit_id":"63a172f797c8b9bae4e366b9314f0f9cd5830817","original_commit_id":"63a172f797c8b9bae4e366b9314f0f9cd5830817","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars0.githubusercontent.com/u/6697940?v=4","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Missing semicolon                  semi","created_at":"2018-05-04T10:05:24Z","updated_at":"2018-05-04T10:05:26Z","html_url":"https://github.com/justega247/Book-a-meal/pull/22#discussion_r186039558","pull_request_url":"https://api.github.com/repos/justega247/Book-a-meal/pulls/22","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/justega247/Book-a-meal/pulls/comments/186039558"},"html":{"href":"https://github.com/justega247/Book-a-meal/pull/22#discussion_r186039558"},"pull_request":{"href":"https://api.github.com/repos/justega247/Book-a-meal/pulls/22"}}},"pull_request":{"url":"https://api.github.com/repos/justega247/Book-a-meal/pulls/22","id":185597682,"html_url":"https://github.com/justega247/Book-a-meal/pull/22","diff_url":"https://github.com/justega247/Book-a-meal/pull/22.diff","patch_url":"https://github.com/justega247/Book-a-meal/pull/22.patch","issue_url":"https://api.github.com/repos/justega247/Book-a-meal/issues/22","number":22,"state":"open","locked":false,"title":"#157270995 Implement feedback for API Endpoints","user":{"login":"justega247","id":31142281,"avatar_url":"https://avatars3.githubusercontent.com/u/31142281?v=4","gravatar_id":"","url":"https://api.github.com/users/justega247","html_url":"https://github.com/justega247","followers_url":"https://api.github.com/users/justega247/followers","following_url":"https://api.github.com/users/justega247/following{/other_user}","gists_url":"https://api.github.com/users/justega247/gists{/gist_id}","starred_url":"https://api.github.com/users/justega247/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justega247/subscriptions","organizations_url":"https://api.github.com/users/justega247/orgs","repos_url":"https://api.github.com/users/justega247/repos","events_url":"https://api.github.com/users/justega247/events{/privacy}","received_events_url":"https://api.github.com/users/justega247/received_events","type":"User","site_admin":false},"body":"#### What does this PR do?\r\n\r\n- This PR is for the Implementation of the feedback i got for my Challenge 2\r\n\r\n#### Description of Task to be completed?\r\n\r\n- Rename my folders properly\r\n- Rename my Variables properly\r\n- Write codes to implement validation\r\n\r\n#### How should this be manually tested?\r\n\r\n- Navigate to the root directory and run ```npm run test```\r\n\r\n#### What are the relevant pivotal tracker stories?\r\n\r\n- https://www.pivotaltracker.com/n/projects/2165563 [#157270995]\r\n","created_at":"2018-05-03T01:07:11Z","updated_at":"2018-05-04T10:05:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"39ab0ae4ab9e0cbaddcc06fecb7af39557a84a58","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/justega247/Book-a-meal/pulls/22/commits","review_comments_url":"https://api.github.com/repos/justega247/Book-a-meal/pulls/22/comments","review_comment_url":"https://api.github.com/repos/justega247/Book-a-meal/pulls/comments{/number}","comments_url":"https://api.github.com/repos/justega247/Book-a-meal/issues/22/comments","statuses_url":"https://api.github.com/repos/justega247/Book-a-meal/statuses/63a172f797c8b9bae4e366b9314f0f9cd5830817","head":{"label":"justega247:feedback","ref":"feedback","sha":"63a172f797c8b9bae4e366b9314f0f9cd5830817","user":{"login":"justega247","id":31142281,"avatar_url":"https://avatars3.githubusercontent.com/u/31142281?v=4","gravatar_id":"","url":"https://api.github.com/users/justega247","html_url":"https://github.com/justega247","followers_url":"https://api.github.com/users/justega247/followers","following_url":"https://api.github.com/users/justega247/following{/other_user}","gists_url":"https://api.github.com/users/justega247/gists{/gist_id}","starred_url":"https://api.github.com/users/justega247/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justega247/subscriptions","organizations_url":"https://api.github.com/users/justega247/orgs","repos_url":"https://api.github.com/users/justega247/repos","events_url":"https://api.github.com/users/justega247/events{/privacy}","received_events_url":"https://api.github.com/users/justega247/received_events","type":"User","site_admin":false},"repo":{"id":129733024,"name":"Book-a-meal","full_name":"justega247/Book-a-meal","owner":{"login":"justega247","id":31142281,"avatar_url":"https://avatars3.githubusercontent.com/u/31142281?v=4","gravatar_id":"","url":"https://api.github.com/users/justega247","html_url":"https://github.com/justega247","followers_url":"https://api.github.com/users/justega247/followers","following_url":"https://api.github.com/users/justega247/following{/other_user}","gists_url":"https://api.github.com/users/justega247/gists{/gist_id}","starred_url":"https://api.github.com/users/justega247/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justega247/subscriptions","organizations_url":"https://api.github.com/users/justega247/orgs","repos_url":"https://api.github.com/users/justega247/repos","events_url":"https://api.github.com/users/justega247/events{/privacy}","received_events_url":"https://api.github.com/users/justega247/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/justega247/Book-a-meal","description":"Book-A-Meal is an application that allows customers to make food orders and helps the food vendor know what the customers want to eat.","fork":false,"url":"https://api.github.com/repos/justega247/Book-a-meal","forks_url":"https://api.github.com/repos/justega247/Book-a-meal/forks","keys_url":"https://api.github.com/repos/justega247/Book-a-meal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/justega247/Book-a-meal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/justega247/Book-a-meal/teams","hooks_url":"https://api.github.com/repos/justega247/Book-a-meal/hooks","issue_events_url":"https://api.github.com/repos/justega247/Book-a-meal/issues/events{/number}","events_url":"https://api.github.com/repos/justega247/Book-a-meal/events","assignees_url":"https://api.github.com/repos/justega247/Book-a-meal/assignees{/user}","branches_url":"https://api.github.com/repos/justega247/Book-a-meal/branches{/branch}","tags_url":"https://api.github.com/repos/justega247/Book-a-meal/tags","blobs_url":"https://api.github.com/repos/justega247/Book-a-meal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/justega247/Book-a-meal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/justega247/Book-a-meal/git/refs{/sha}","trees_url":"https://api.github.com/repos/justega247/Book-a-meal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/justega247/Book-a-meal/statuses/{sha}","languages_url":"https://api.github.com/repos/justega247/Book-a-meal/languages","stargazers_url":"https://api.github.com/repos/justega247/Book-a-meal/stargazers","contributors_url":"https://api.github.com/repos/justega247/Book-a-meal/contributors","subscribers_url":"https://api.github.com/repos/justega247/Book-a-meal/subscribers","subscription_url":"https://api.github.com/repos/justega247/Book-a-meal/subscription","commits_url":"https://api.github.com/repos/justega247/Book-a-meal/commits{/sha}","git_commits_url":"https://api.github.com/repos/justega247/Book-a-meal/git/commits{/sha}","comments_url":"https://api.github.com/repos/justega247/Book-a-meal/comments{/number}","issue_comment_url":"https://api.github.com/repos/justega247/Book-a-meal/issues/comments{/number}","contents_url":"https://api.github.com/repos/justega247/Book-a-meal/contents/{+path}","compare_url":"https://api.github.com/repos/justega247/Book-a-meal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/justega247/Book-a-meal/merges","archive_url":"https://api.github.com/repos/justega247/Book-a-meal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/justega247/Book-a-meal/downloads","issues_url":"https://api.github.com/repos/justega247/Book-a-meal/issues{/number}","pulls_url":"https://api.github.com/repos/justega247/Book-a-meal/pulls{/number}","milestones_url":"https://api.github.com/repos/justega247/Book-a-meal/milestones{/number}","notifications_url":"https://api.github.com/repos/justega247/Book-a-meal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/justega247/Book-a-meal/labels{/name}","releases_url":"https://api.github.com/repos/justega247/Book-a-meal/releases{/id}","deployments_url":"https://api.github.com/repos/justega247/Book-a-meal/deployments","created_at":"2018-04-16T11:35:21Z","updated_at":"2018-05-02T15:44:36Z","pushed_at":"2018-05-04T10:04:53Z","git_url":"git://github.com/justega247/Book-a-meal.git","ssh_url":"git@github.com:justega247/Book-a-meal.git","clone_url":"https://github.com/justega247/Book-a-meal.git","svn_url":"https://github.com/justega247/Book-a-meal","homepage":null,"size":105,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":0,"open_issues":2,"watchers":0,"default_branch":"develop"}},"base":{"label":"justega247:develop","ref":"develop","sha":"4987ef9ecef2921c2b032307fb5aca01999c39bf","user":{"login":"justega247","id":31142281,"avatar_url":"https://avatars3.githubusercontent.com/u/31142281?v=4","gravatar_id":"","url":"https://api.github.com/users/justega247","html_url":"https://github.com/justega247","followers_url":"https://api.github.com/users/justega247/followers","following_url":"https://api.github.com/users/justega247/following{/other_user}","gists_url":"https://api.github.com/users/justega247/gists{/gist_id}","starred_url":"https://api.github.com/users/justega247/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justega247/subscriptions","organizations_url":"https://api.github.com/users/justega247/orgs","repos_url":"https://api.github.com/users/justega247/repos","events_url":"https://api.github.com/users/justega247/events{/privacy}","received_events_url":"https://api.github.com/users/justega247/received_events","type":"User","site_admin":false},"repo":{"id":129733024,"name":"Book-a-meal","full_name":"justega247/Book-a-meal","owner":{"login":"justega247","id":31142281,"avatar_url":"https://avatars3.githubusercontent.com/u/31142281?v=4","gravatar_id":"","url":"https://api.github.com/users/justega247","html_url":"https://github.com/justega247","followers_url":"https://api.github.com/users/justega247/followers","following_url":"https://api.github.com/users/justega247/following{/other_user}","gists_url":"https://api.github.com/users/justega247/gists{/gist_id}","starred_url":"https://api.github.com/users/justega247/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justega247/subscriptions","organizations_url":"https://api.github.com/users/justega247/orgs","repos_url":"https://api.github.com/users/justega247/repos","events_url":"https://api.github.com/users/justega247/events{/privacy}","received_events_url":"https://api.github.com/users/justega247/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/justega247/Book-a-meal","description":"Book-A-Meal is an application that allows customers to make food orders and helps the food vendor know what the customers want to eat.","fork":false,"url":"https://api.github.com/repos/justega247/Book-a-meal","forks_url":"https://api.github.com/repos/justega247/Book-a-meal/forks","keys_url":"https://api.github.com/repos/justega247/Book-a-meal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/justega247/Book-a-meal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/justega247/Book-a-meal/teams","hooks_url":"https://api.github.com/repos/justega247/Book-a-meal/hooks","issue_events_url":"https://api.github.com/repos/justega247/Book-a-meal/issues/events{/number}","events_url":"https://api.github.com/repos/justega247/Book-a-meal/events","assignees_url":"https://api.github.com/repos/justega247/Book-a-meal/assignees{/user}","branches_url":"https://api.github.com/repos/justega247/Book-a-meal/branches{/branch}","tags_url":"https://api.github.com/repos/justega247/Book-a-meal/tags","blobs_url":"https://api.github.com/repos/justega247/Book-a-meal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/justega247/Book-a-meal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/justega247/Book-a-meal/git/refs{/sha}","trees_url":"https://api.github.com/repos/justega247/Book-a-meal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/justega247/Book-a-meal/statuses/{sha}","languages_url":"https://api.github.com/repos/justega247/Book-a-meal/languages","stargazers_url":"https://api.github.com/repos/justega247/Book-a-meal/stargazers","contributors_url":"https://api.github.com/repos/justega247/Book-a-meal/contributors","subscribers_url":"https://api.github.com/repos/justega247/Book-a-meal/subscribers","subscription_url":"https://api.github.com/repos/justega247/Book-a-meal/subscription","commits_url":"https://api.github.com/repos/justega247/Book-a-meal/commits{/sha}","git_commits_url":"https://api.github.com/repos/justega247/Book-a-meal/git/commits{/sha}","comments_url":"https://api.github.com/repos/justega247/Book-a-meal/comments{/number}","issue_comment_url":"https://api.github.com/repos/justega247/Book-a-meal/issues/comments{/number}","contents_url":"https://api.github.com/repos/justega247/Book-a-meal/contents/{+path}","compare_url":"https://api.github.com/repos/justega247/Book-a-meal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/justega247/Book-a-meal/merges","archive_url":"https://api.github.com/repos/justega247/Book-a-meal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/justega247/Book-a-meal/downloads","issues_url":"https://api.github.com/repos/justega247/Book-a-meal/issues{/number}","pulls_url":"https://api.github.com/repos/justega247/Book-a-meal/pulls{/number}","milestones_url":"https://api.github.com/repos/justega247/Book-a-meal/milestones{/number}","notifications_url":"https://api.github.com/repos/justega247/Book-a-meal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/justega247/Book-a-meal/labels{/name}","releases_url":"https://api.github.com/repos/justega247/Book-a-meal/releases{/id}","deployments_url":"https://api.github.com/repos/justega247/Book-a-meal/deployments","created_at":"2018-04-16T11:35:21Z","updated_at":"2018-05-02T15:44:36Z","pushed_at":"2018-05-04T10:04:53Z","git_url":"git://github.com/justega247/Book-a-meal.git","ssh_url":"git@github.com:justega247/Book-a-meal.git","clone_url":"https://github.com/justega247/Book-a-meal.git","svn_url":"https://github.com/justega247/Book-a-meal","homepage":null,"size":105,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":0,"open_issues":2,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/justega247/Book-a-meal/pulls/22"},"html":{"href":"https://github.com/justega247/Book-a-meal/pull/22"},"issue":{"href":"https://api.github.com/repos/justega247/Book-a-meal/issues/22"},"comments":{"href":"https://api.github.com/repos/justega247/Book-a-meal/issues/22/comments"},"review_comments":{"href":"https://api.github.com/repos/justega247/Book-a-meal/pulls/22/comments"},"review_comment":{"href":"https://api.github.com/repos/justega247/Book-a-meal/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/justega247/Book-a-meal/pulls/22/commits"},"statuses":{"href":"https://api.github.com/repos/justega247/Book-a-meal/statuses/63a172f797c8b9bae4e366b9314f0f9cd5830817"}},"author_association":"OWNER"}}
{"actor":{"display_login":"houndci-bot"}}