{"action":"created","comment":{"url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/comments/33562351","id":33562351,"diff_hunk":"@@ -28,21 +38,49 @@ define(['$', 'modules/checkout/form-elements', 'modules/checkout/regex'], functi\n     }\n \n     var validatePersonalDetails = function () {\n-        var emptyFields = mandatoryFieldsPersonalDetails.filter(function (field) {\n-            var isEmpty = field.input.val() === '';\n-            toggleError(field.container, isEmpty);\n-            return isEmpty;\n+\n+        var staticValidations = new Promise(function (onSuccess, onFailure){\n+            var emptyFields = mandatoryFieldsPersonalDetails.filter(function (field) {\n+                var isEmpty = field.input.val() === '';\n+                toggleError(field.container, isEmpty);\n+                return isEmpty;\n+            });\n+            var noEmptyFields = emptyFields.length === 0;\n+\n+            var validEmail = regex.isValidEmail(form.$EMAIL.val());\n+            renderEmailError(!validEmail);\n+            toggleError(form.$EMAIL_CONTAINER, !validEmail);","path":"assets/javascripts/modules/checkout/validations.js","position":40,"original_position":40,"commit_id":"bde00836a87938e47b8305b3a3280860c3e33249","original_commit_id":"bde00836a87938e47b8305b3a3280860c3e33249","user":{"login":"davidrapson","id":123386,"avatar_url":"https://avatars.githubusercontent.com/u/123386?v=3","gravatar_id":"","url":"https://api.github.com/users/davidrapson","html_url":"https://github.com/davidrapson","followers_url":"https://api.github.com/users/davidrapson/followers","following_url":"https://api.github.com/users/davidrapson/following{/other_user}","gists_url":"https://api.github.com/users/davidrapson/gists{/gist_id}","starred_url":"https://api.github.com/users/davidrapson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidrapson/subscriptions","organizations_url":"https://api.github.com/users/davidrapson/orgs","repos_url":"https://api.github.com/users/davidrapson/repos","events_url":"https://api.github.com/users/davidrapson/events{/privacy}","received_events_url":"https://api.github.com/users/davidrapson/received_events","type":"User","site_admin":false},"body":"Another option might be, instead on performing side-effects inside the promise you pass an object to the `resolve` method with validation information about each field?","created_at":"2015-06-30T11:19:47Z","updated_at":"2015-06-30T11:19:47Z","html_url":"https://github.com/guardian/subscriptions-frontend/pull/56#discussion_r33562351","pull_request_url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/56","_links":{"self":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/comments/33562351"},"html":{"href":"https://github.com/guardian/subscriptions-frontend/pull/56#discussion_r33562351"},"pull_request":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/56"}}},"pull_request":{"url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/56","id":38860749,"html_url":"https://github.com/guardian/subscriptions-frontend/pull/56","diff_url":"https://github.com/guardian/subscriptions-frontend/pull/56.diff","patch_url":"https://github.com/guardian/subscriptions-frontend/pull/56.patch","issue_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/56","number":56,"state":"open","locked":false,"title":"Display error message if email is taken","user":{"login":"tudorraul","id":1492162,"avatar_url":"https://avatars.githubusercontent.com/u/1492162?v=3","gravatar_id":"","url":"https://api.github.com/users/tudorraul","html_url":"https://github.com/tudorraul","followers_url":"https://api.github.com/users/tudorraul/followers","following_url":"https://api.github.com/users/tudorraul/following{/other_user}","gists_url":"https://api.github.com/users/tudorraul/gists{/gist_id}","starred_url":"https://api.github.com/users/tudorraul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tudorraul/subscriptions","organizations_url":"https://api.github.com/users/tudorraul/orgs","repos_url":"https://api.github.com/users/tudorraul/repos","events_url":"https://api.github.com/users/tudorraul/events{/privacy}","received_events_url":"https://api.github.com/users/tudorraul/received_events","type":"User","site_admin":false},"body":"This integrates the email check functionality with the checkout form validations.\r\n![screen shot 2015-06-30 at 10 56 03](https://cloud.githubusercontent.com/assets/1492162/8428467/a04ec61a-1f16-11e5-8972-f32dcb59e7e5.png)\r\n","created_at":"2015-06-30T09:56:19Z","updated_at":"2015-06-30T11:19:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"20f96a283d3615075b60d47c322038e467b107c9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/56/commits","review_comments_url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/56/comments","review_comment_url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/56/comments","statuses_url":"https://api.github.com/repos/guardian/subscriptions-frontend/statuses/bde00836a87938e47b8305b3a3280860c3e33249","head":{"label":"guardian:id-email-check-validation","ref":"id-email-check-validation","sha":"bde00836a87938e47b8305b3a3280860c3e33249","user":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"repo":{"id":34392023,"name":"subscriptions-frontend","full_name":"guardian/subscriptions-frontend","owner":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/guardian/subscriptions-frontend","description":"","fork":false,"url":"https://api.github.com/repos/guardian/subscriptions-frontend","forks_url":"https://api.github.com/repos/guardian/subscriptions-frontend/forks","keys_url":"https://api.github.com/repos/guardian/subscriptions-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/subscriptions-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/subscriptions-frontend/teams","hooks_url":"https://api.github.com/repos/guardian/subscriptions-frontend/hooks","issue_events_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/subscriptions-frontend/events","assignees_url":"https://api.github.com/repos/guardian/subscriptions-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/subscriptions-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/subscriptions-frontend/tags","blobs_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/subscriptions-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/subscriptions-frontend/languages","stargazers_url":"https://api.github.com/repos/guardian/subscriptions-frontend/stargazers","contributors_url":"https://api.github.com/repos/guardian/subscriptions-frontend/contributors","subscribers_url":"https://api.github.com/repos/guardian/subscriptions-frontend/subscribers","subscription_url":"https://api.github.com/repos/guardian/subscriptions-frontend/subscription","commits_url":"https://api.github.com/repos/guardian/subscriptions-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/subscriptions-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/subscriptions-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/subscriptions-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/subscriptions-frontend/merges","archive_url":"https://api.github.com/repos/guardian/subscriptions-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/subscriptions-frontend/downloads","issues_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/subscriptions-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/subscriptions-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/subscriptions-frontend/labels{/name}","releases_url":"https://api.github.com/repos/guardian/subscriptions-frontend/releases{/id}","created_at":"2015-04-22T13:30:13Z","updated_at":"2015-06-08T09:08:52Z","pushed_at":"2015-06-30T10:53:23Z","git_url":"git://github.com/guardian/subscriptions-frontend.git","ssh_url":"git@github.com:guardian/subscriptions-frontend.git","clone_url":"https://github.com/guardian/subscriptions-frontend.git","svn_url":"https://github.com/guardian/subscriptions-frontend","homepage":"https://sites.google.com/a/guardian.co.uk/guardian-subscriptions/","size":3128,"stargazers_count":1,"watchers_count":1,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"guardian:master","ref":"master","sha":"112da4bc21f3f3a2bbbf2b76115ff395729b054c","user":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"repo":{"id":34392023,"name":"subscriptions-frontend","full_name":"guardian/subscriptions-frontend","owner":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/guardian/subscriptions-frontend","description":"","fork":false,"url":"https://api.github.com/repos/guardian/subscriptions-frontend","forks_url":"https://api.github.com/repos/guardian/subscriptions-frontend/forks","keys_url":"https://api.github.com/repos/guardian/subscriptions-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/subscriptions-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/subscriptions-frontend/teams","hooks_url":"https://api.github.com/repos/guardian/subscriptions-frontend/hooks","issue_events_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/subscriptions-frontend/events","assignees_url":"https://api.github.com/repos/guardian/subscriptions-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/subscriptions-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/subscriptions-frontend/tags","blobs_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/subscriptions-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/subscriptions-frontend/languages","stargazers_url":"https://api.github.com/repos/guardian/subscriptions-frontend/stargazers","contributors_url":"https://api.github.com/repos/guardian/subscriptions-frontend/contributors","subscribers_url":"https://api.github.com/repos/guardian/subscriptions-frontend/subscribers","subscription_url":"https://api.github.com/repos/guardian/subscriptions-frontend/subscription","commits_url":"https://api.github.com/repos/guardian/subscriptions-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/subscriptions-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/subscriptions-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/subscriptions-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/subscriptions-frontend/merges","archive_url":"https://api.github.com/repos/guardian/subscriptions-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/subscriptions-frontend/downloads","issues_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/subscriptions-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/subscriptions-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/subscriptions-frontend/labels{/name}","releases_url":"https://api.github.com/repos/guardian/subscriptions-frontend/releases{/id}","created_at":"2015-04-22T13:30:13Z","updated_at":"2015-06-08T09:08:52Z","pushed_at":"2015-06-30T10:53:23Z","git_url":"git://github.com/guardian/subscriptions-frontend.git","ssh_url":"git@github.com:guardian/subscriptions-frontend.git","clone_url":"https://github.com/guardian/subscriptions-frontend.git","svn_url":"https://github.com/guardian/subscriptions-frontend","homepage":"https://sites.google.com/a/guardian.co.uk/guardian-subscriptions/","size":3128,"stargazers_count":1,"watchers_count":1,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/56"},"html":{"href":"https://github.com/guardian/subscriptions-frontend/pull/56"},"issue":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/56"},"comments":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/56/comments"},"review_comments":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/56/comments"},"review_comment":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/56/commits"},"statuses":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/statuses/bde00836a87938e47b8305b3a3280860c3e33249"}}}}