{"action":"created","comment":{"url":"https://api.github.com/repos/hmcts/one-per-page/pulls/comments/200315132","pull_request_review_id":134604809,"id":200315132,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMDMxNTEzMg==","diff_hunk":"@@ -105,12 +105,19 @@ class AddAnother extends Question {\n     } else if (req.method === 'POST') {\n       this.parse();\n       this.validate();\n-\n       if (this.valid) {\n         this.store();\n-        res.redirect(this.path);\n+        if (this.xhr) {\n+          res.status(OK).json({ validationErrors: [] });\n+        } else {\n+          res.redirect(this.path);\n+        }\n       } else {\n-        res.render(this.template, this.locals);\n+        if (this.xhr) {\n+          res.json(this.buildValidationErrors);","path":"src/steps/AddAnother.js","position":25,"original_position":25,"commit_id":"41c09388681c366cce682367e7596e2fe61bb406","original_commit_id":"41c09388681c366cce682367e7596e2fe61bb406","user":{"login":"barbaracassani","id":853989,"node_id":"MDQ6VXNlcjg1Mzk4OQ==","avatar_url":"https://avatars0.githubusercontent.com/u/853989?v=4","gravatar_id":"","url":"https://api.github.com/users/barbaracassani","html_url":"https://github.com/barbaracassani","followers_url":"https://api.github.com/users/barbaracassani/followers","following_url":"https://api.github.com/users/barbaracassani/following{/other_user}","gists_url":"https://api.github.com/users/barbaracassani/gists{/gist_id}","starred_url":"https://api.github.com/users/barbaracassani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/barbaracassani/subscriptions","organizations_url":"https://api.github.com/users/barbaracassani/orgs","repos_url":"https://api.github.com/users/barbaracassani/repos","events_url":"https://api.github.com/users/barbaracassani/events{/privacy}","received_events_url":"https://api.github.com/users/barbaracassani/received_events","type":"User","site_admin":false},"body":"@bendiggle can you pls change this to \r\n`res.status(UNPROCESSABLE_ENTITY).json(er);` -- I need it :)\r\n\r\n(btw you also need to import the thingie at the top)","created_at":"2018-07-05T11:11:45Z","updated_at":"2018-07-05T11:11:45Z","html_url":"https://github.com/hmcts/one-per-page/pull/126#discussion_r200315132","pull_request_url":"https://api.github.com/repos/hmcts/one-per-page/pulls/126","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/hmcts/one-per-page/pulls/comments/200315132"},"html":{"href":"https://github.com/hmcts/one-per-page/pull/126#discussion_r200315132"},"pull_request":{"href":"https://api.github.com/repos/hmcts/one-per-page/pulls/126"}}},"pull_request":{"url":"https://api.github.com/repos/hmcts/one-per-page/pulls/126","id":194593096,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk0NTkzMDk2","html_url":"https://github.com/hmcts/one-per-page/pull/126","diff_url":"https://github.com/hmcts/one-per-page/pull/126.diff","patch_url":"https://github.com/hmcts/one-per-page/pull/126.patch","issue_url":"https://api.github.com/repos/hmcts/one-per-page/issues/126","number":126,"state":"open","locked":false,"title":"AJAX Validation handling","user":{"login":"bendiggle","id":11047071,"node_id":"MDQ6VXNlcjExMDQ3MDcx","avatar_url":"https://avatars2.githubusercontent.com/u/11047071?v=4","gravatar_id":"","url":"https://api.github.com/users/bendiggle","html_url":"https://github.com/bendiggle","followers_url":"https://api.github.com/users/bendiggle/followers","following_url":"https://api.github.com/users/bendiggle/following{/other_user}","gists_url":"https://api.github.com/users/bendiggle/gists{/gist_id}","starred_url":"https://api.github.com/users/bendiggle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bendiggle/subscriptions","organizations_url":"https://api.github.com/users/bendiggle/orgs","repos_url":"https://api.github.com/users/bendiggle/repos","events_url":"https://api.github.com/users/bendiggle/events{/privacy}","received_events_url":"https://api.github.com/users/bendiggle/received_events","type":"User","site_admin":false},"body":"- This is to handle validation errors when using to AJAX to post values within the Add Another class.\r\n- It checks if the request is an AJAX or not and if so build an object that contains the field within `item` and its errors.\r\n- Then send it to the AJAX callback.\r\n\r\nThis is what is the errors object looks like:\r\n```\r\n{ validationErrors: [{ \r\n        field: 'whatYouDisagreeWith', errors: [Array], value: 'invalid field value' \r\n    }, { \r\n        field: 'reasonForAppealing', errors: [Array], value: 'invalid field value' \r\n    } \r\n]}\r\n```\r\n\r\n- Added the ability to use ajax to get the values of the fields\r\n- Added unit tests for all","created_at":"2018-06-13T13:49:35Z","updated_at":"2018-07-05T11:11:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f32e953a5aa3cd9ac2e0c2a0e0b09ed73c2a0fcd","assignee":null,"assignees":[],"requested_reviewers":[{"login":"paulgain","id":964268,"node_id":"MDQ6VXNlcjk2NDI2OA==","avatar_url":"https://avatars0.githubusercontent.com/u/964268?v=4","gravatar_id":"","url":"https://api.github.com/users/paulgain","html_url":"https://github.com/paulgain","followers_url":"https://api.github.com/users/paulgain/followers","following_url":"https://api.github.com/users/paulgain/following{/other_user}","gists_url":"https://api.github.com/users/paulgain/gists{/gist_id}","starred_url":"https://api.github.com/users/paulgain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulgain/subscriptions","organizations_url":"https://api.github.com/users/paulgain/orgs","repos_url":"https://api.github.com/users/paulgain/repos","events_url":"https://api.github.com/users/paulgain/events{/privacy}","received_events_url":"https://api.github.com/users/paulgain/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/hmcts/one-per-page/pulls/126/commits","review_comments_url":"https://api.github.com/repos/hmcts/one-per-page/pulls/126/comments","review_comment_url":"https://api.github.com/repos/hmcts/one-per-page/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hmcts/one-per-page/issues/126/comments","statuses_url":"https://api.github.com/repos/hmcts/one-per-page/statuses/41c09388681c366cce682367e7596e2fe61bb406","head":{"label":"hmcts:ajax-validation-handling","ref":"ajax-validation-handling","sha":"41c09388681c366cce682367e7596e2fe61bb406","user":{"login":"hmcts","id":22817111,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyODE3MTEx","avatar_url":"https://avatars1.githubusercontent.com/u/22817111?v=4","gravatar_id":"","url":"https://api.github.com/users/hmcts","html_url":"https://github.com/hmcts","followers_url":"https://api.github.com/users/hmcts/followers","following_url":"https://api.github.com/users/hmcts/following{/other_user}","gists_url":"https://api.github.com/users/hmcts/gists{/gist_id}","starred_url":"https://api.github.com/users/hmcts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmcts/subscriptions","organizations_url":"https://api.github.com/users/hmcts/orgs","repos_url":"https://api.github.com/users/hmcts/repos","events_url":"https://api.github.com/users/hmcts/events{/privacy}","received_events_url":"https://api.github.com/users/hmcts/received_events","type":"Organization","site_admin":false},"repo":{"id":97947158,"node_id":"MDEwOlJlcG9zaXRvcnk5Nzk0NzE1OA==","name":"one-per-page","full_name":"hmcts/one-per-page","owner":{"login":"hmcts","id":22817111,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyODE3MTEx","avatar_url":"https://avatars1.githubusercontent.com/u/22817111?v=4","gravatar_id":"","url":"https://api.github.com/users/hmcts","html_url":"https://github.com/hmcts","followers_url":"https://api.github.com/users/hmcts/followers","following_url":"https://api.github.com/users/hmcts/following{/other_user}","gists_url":"https://api.github.com/users/hmcts/gists{/gist_id}","starred_url":"https://api.github.com/users/hmcts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmcts/subscriptions","organizations_url":"https://api.github.com/users/hmcts/orgs","repos_url":"https://api.github.com/users/hmcts/repos","events_url":"https://api.github.com/users/hmcts/events{/privacy}","received_events_url":"https://api.github.com/users/hmcts/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hmcts/one-per-page","description":"GOV.UK style one question per page transactions made easy","fork":false,"url":"https://api.github.com/repos/hmcts/one-per-page","forks_url":"https://api.github.com/repos/hmcts/one-per-page/forks","keys_url":"https://api.github.com/repos/hmcts/one-per-page/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hmcts/one-per-page/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hmcts/one-per-page/teams","hooks_url":"https://api.github.com/repos/hmcts/one-per-page/hooks","issue_events_url":"https://api.github.com/repos/hmcts/one-per-page/issues/events{/number}","events_url":"https://api.github.com/repos/hmcts/one-per-page/events","assignees_url":"https://api.github.com/repos/hmcts/one-per-page/assignees{/user}","branches_url":"https://api.github.com/repos/hmcts/one-per-page/branches{/branch}","tags_url":"https://api.github.com/repos/hmcts/one-per-page/tags","blobs_url":"https://api.github.com/repos/hmcts/one-per-page/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hmcts/one-per-page/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hmcts/one-per-page/git/refs{/sha}","trees_url":"https://api.github.com/repos/hmcts/one-per-page/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hmcts/one-per-page/statuses/{sha}","languages_url":"https://api.github.com/repos/hmcts/one-per-page/languages","stargazers_url":"https://api.github.com/repos/hmcts/one-per-page/stargazers","contributors_url":"https://api.github.com/repos/hmcts/one-per-page/contributors","subscribers_url":"https://api.github.com/repos/hmcts/one-per-page/subscribers","subscription_url":"https://api.github.com/repos/hmcts/one-per-page/subscription","commits_url":"https://api.github.com/repos/hmcts/one-per-page/commits{/sha}","git_commits_url":"https://api.github.com/repos/hmcts/one-per-page/git/commits{/sha}","comments_url":"https://api.github.com/repos/hmcts/one-per-page/comments{/number}","issue_comment_url":"https://api.github.com/repos/hmcts/one-per-page/issues/comments{/number}","contents_url":"https://api.github.com/repos/hmcts/one-per-page/contents/{+path}","compare_url":"https://api.github.com/repos/hmcts/one-per-page/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hmcts/one-per-page/merges","archive_url":"https://api.github.com/repos/hmcts/one-per-page/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hmcts/one-per-page/downloads","issues_url":"https://api.github.com/repos/hmcts/one-per-page/issues{/number}","pulls_url":"https://api.github.com/repos/hmcts/one-per-page/pulls{/number}","milestones_url":"https://api.github.com/repos/hmcts/one-per-page/milestones{/number}","notifications_url":"https://api.github.com/repos/hmcts/one-per-page/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hmcts/one-per-page/labels{/name}","releases_url":"https://api.github.com/repos/hmcts/one-per-page/releases{/id}","deployments_url":"https://api.github.com/repos/hmcts/one-per-page/deployments","created_at":"2017-07-21T12:51:21Z","updated_at":"2018-06-12T14:03:11Z","pushed_at":"2018-07-04T14:09:48Z","git_url":"git://github.com/hmcts/one-per-page.git","ssh_url":"git@github.com:hmcts/one-per-page.git","clone_url":"https://github.com/hmcts/one-per-page.git","svn_url":"https://github.com/hmcts/one-per-page","homepage":"https://one-per-page.herokuapp.com","size":1570,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":16,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":3,"open_issues":16,"watchers":3,"default_branch":"master"}},"base":{"label":"hmcts:master","ref":"master","sha":"d8fa3da29dbac0a421d9ffdf40d17124f5343039","user":{"login":"hmcts","id":22817111,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyODE3MTEx","avatar_url":"https://avatars1.githubusercontent.com/u/22817111?v=4","gravatar_id":"","url":"https://api.github.com/users/hmcts","html_url":"https://github.com/hmcts","followers_url":"https://api.github.com/users/hmcts/followers","following_url":"https://api.github.com/users/hmcts/following{/other_user}","gists_url":"https://api.github.com/users/hmcts/gists{/gist_id}","starred_url":"https://api.github.com/users/hmcts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmcts/subscriptions","organizations_url":"https://api.github.com/users/hmcts/orgs","repos_url":"https://api.github.com/users/hmcts/repos","events_url":"https://api.github.com/users/hmcts/events{/privacy}","received_events_url":"https://api.github.com/users/hmcts/received_events","type":"Organization","site_admin":false},"repo":{"id":97947158,"node_id":"MDEwOlJlcG9zaXRvcnk5Nzk0NzE1OA==","name":"one-per-page","full_name":"hmcts/one-per-page","owner":{"login":"hmcts","id":22817111,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyODE3MTEx","avatar_url":"https://avatars1.githubusercontent.com/u/22817111?v=4","gravatar_id":"","url":"https://api.github.com/users/hmcts","html_url":"https://github.com/hmcts","followers_url":"https://api.github.com/users/hmcts/followers","following_url":"https://api.github.com/users/hmcts/following{/other_user}","gists_url":"https://api.github.com/users/hmcts/gists{/gist_id}","starred_url":"https://api.github.com/users/hmcts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmcts/subscriptions","organizations_url":"https://api.github.com/users/hmcts/orgs","repos_url":"https://api.github.com/users/hmcts/repos","events_url":"https://api.github.com/users/hmcts/events{/privacy}","received_events_url":"https://api.github.com/users/hmcts/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hmcts/one-per-page","description":"GOV.UK style one question per page transactions made easy","fork":false,"url":"https://api.github.com/repos/hmcts/one-per-page","forks_url":"https://api.github.com/repos/hmcts/one-per-page/forks","keys_url":"https://api.github.com/repos/hmcts/one-per-page/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hmcts/one-per-page/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hmcts/one-per-page/teams","hooks_url":"https://api.github.com/repos/hmcts/one-per-page/hooks","issue_events_url":"https://api.github.com/repos/hmcts/one-per-page/issues/events{/number}","events_url":"https://api.github.com/repos/hmcts/one-per-page/events","assignees_url":"https://api.github.com/repos/hmcts/one-per-page/assignees{/user}","branches_url":"https://api.github.com/repos/hmcts/one-per-page/branches{/branch}","tags_url":"https://api.github.com/repos/hmcts/one-per-page/tags","blobs_url":"https://api.github.com/repos/hmcts/one-per-page/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hmcts/one-per-page/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hmcts/one-per-page/git/refs{/sha}","trees_url":"https://api.github.com/repos/hmcts/one-per-page/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hmcts/one-per-page/statuses/{sha}","languages_url":"https://api.github.com/repos/hmcts/one-per-page/languages","stargazers_url":"https://api.github.com/repos/hmcts/one-per-page/stargazers","contributors_url":"https://api.github.com/repos/hmcts/one-per-page/contributors","subscribers_url":"https://api.github.com/repos/hmcts/one-per-page/subscribers","subscription_url":"https://api.github.com/repos/hmcts/one-per-page/subscription","commits_url":"https://api.github.com/repos/hmcts/one-per-page/commits{/sha}","git_commits_url":"https://api.github.com/repos/hmcts/one-per-page/git/commits{/sha}","comments_url":"https://api.github.com/repos/hmcts/one-per-page/comments{/number}","issue_comment_url":"https://api.github.com/repos/hmcts/one-per-page/issues/comments{/number}","contents_url":"https://api.github.com/repos/hmcts/one-per-page/contents/{+path}","compare_url":"https://api.github.com/repos/hmcts/one-per-page/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hmcts/one-per-page/merges","archive_url":"https://api.github.com/repos/hmcts/one-per-page/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hmcts/one-per-page/downloads","issues_url":"https://api.github.com/repos/hmcts/one-per-page/issues{/number}","pulls_url":"https://api.github.com/repos/hmcts/one-per-page/pulls{/number}","milestones_url":"https://api.github.com/repos/hmcts/one-per-page/milestones{/number}","notifications_url":"https://api.github.com/repos/hmcts/one-per-page/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hmcts/one-per-page/labels{/name}","releases_url":"https://api.github.com/repos/hmcts/one-per-page/releases{/id}","deployments_url":"https://api.github.com/repos/hmcts/one-per-page/deployments","created_at":"2017-07-21T12:51:21Z","updated_at":"2018-06-12T14:03:11Z","pushed_at":"2018-07-04T14:09:48Z","git_url":"git://github.com/hmcts/one-per-page.git","ssh_url":"git@github.com:hmcts/one-per-page.git","clone_url":"https://github.com/hmcts/one-per-page.git","svn_url":"https://github.com/hmcts/one-per-page","homepage":"https://one-per-page.herokuapp.com","size":1570,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":16,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":3,"open_issues":16,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hmcts/one-per-page/pulls/126"},"html":{"href":"https://github.com/hmcts/one-per-page/pull/126"},"issue":{"href":"https://api.github.com/repos/hmcts/one-per-page/issues/126"},"comments":{"href":"https://api.github.com/repos/hmcts/one-per-page/issues/126/comments"},"review_comments":{"href":"https://api.github.com/repos/hmcts/one-per-page/pulls/126/comments"},"review_comment":{"href":"https://api.github.com/repos/hmcts/one-per-page/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hmcts/one-per-page/pulls/126/commits"},"statuses":{"href":"https://api.github.com/repos/hmcts/one-per-page/statuses/41c09388681c366cce682367e7596e2fe61bb406"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"barbaracassani"}}