{"action":"created","comment":{"url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/pulls/comments/26755489","id":26755489,"diff_hunk":"@@ -42,24 +42,24 @@ module.exports = Validators = {\n     },\n \n     numeric: function numeric(value) {\n-        return Validators.regex(value, /^\\d+$/);\n+        return Validators.regex(value, /^\\d*$/);\n     },\n \n     equal: function equal(value) {\n         var values = [].slice.call(arguments, 1);\n-        return values.length && _.any(values, function (c) { return value === c; });\n+        return values.length && _.any(values, function (c) { return value === c || value === ''; });","path":"lib/validation/validators.js","position":36,"original_position":36,"commit_id":"71061cb2ddb87706b6e8cd9c6643dddcbedf9b43","original_commit_id":"71061cb2ddb87706b6e8cd9c6643dddcbedf9b43","user":{"login":"lennym","id":117398,"avatar_url":"https://avatars.githubusercontent.com/u/117398?v=3","gravatar_id":"","url":"https://api.github.com/users/lennym","html_url":"https://github.com/lennym","followers_url":"https://api.github.com/users/lennym/followers","following_url":"https://api.github.com/users/lennym/following{/other_user}","gists_url":"https://api.github.com/users/lennym/gists{/gist_id}","starred_url":"https://api.github.com/users/lennym/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lennym/subscriptions","organizations_url":"https://api.github.com/users/lennym/orgs","repos_url":"https://api.github.com/users/lennym/repos","events_url":"https://api.github.com/users/lennym/events{/privacy}","received_events_url":"https://api.github.com/users/lennym/received_events","type":"User","site_admin":false},"body":"The `|| value === ''` should probably live outside the `_.any` call. We don't need to the check the value against an empty string for every possible value.\r\n\r\n`return values.length && (value === '' || _.any(values, function (c) { return value === c; }));`","created_at":"2015-03-19T13:52:36Z","updated_at":"2015-03-19T13:52:36Z","html_url":"https://github.com/UKHomeOffice/passports-form-controller/pull/13#discussion_r26755489","pull_request_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/pulls/comments/26755489"},"html":{"href":"https://github.com/UKHomeOffice/passports-form-controller/pull/13#discussion_r26755489"},"pull_request":{"href":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/pulls/13","id":31522430,"html_url":"https://github.com/UKHomeOffice/passports-form-controller/pull/13","diff_url":"https://github.com/UKHomeOffice/passports-form-controller/pull/13.diff","patch_url":"https://github.com/UKHomeOffice/passports-form-controller/pull/13.patch","issue_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/issues/13","number":13,"state":"open","locked":false,"title":"#5: Validators are not implicitly required.","user":{"login":"sebinsua","id":152098,"avatar_url":"https://avatars.githubusercontent.com/u/152098?v=3","gravatar_id":"","url":"https://api.github.com/users/sebinsua","html_url":"https://github.com/sebinsua","followers_url":"https://api.github.com/users/sebinsua/followers","following_url":"https://api.github.com/users/sebinsua/following{/other_user}","gists_url":"https://api.github.com/users/sebinsua/gists{/gist_id}","starred_url":"https://api.github.com/users/sebinsua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebinsua/subscriptions","organizations_url":"https://api.github.com/users/sebinsua/orgs","repos_url":"https://api.github.com/users/sebinsua/repos","events_url":"https://api.github.com/users/sebinsua/events{/privacy}","received_events_url":"https://api.github.com/users/sebinsua/received_events","type":"User","site_admin":false},"body":"See: https://github.com/UKHomeOffice/passports-form-controller/issues/5\r\n\r\nBy default the application of a validator is optional on empty strings. If you need to ensure a field is validated as being 9 characters long and exists then you need to use both an `exactlength` and a `required` validator.\r\n\r\nIn a couple of cases I amended a regex to no longer only match for more than one character but in other cases where the code was more complex I put an explicit check for an empty string since this it's easier to read.\r\n\r\nThe `regex` validator does not pass for an empty string by default as it would be bad to alter the expected behaviour (full control over what is being tested for with the possibility of making things required.)\r\n\r\nAll of the tests pass but these changes affect a large number of validators so tread carefully in terms of merging, and make sure that all of your non-optional fields have a `required` validator against them.","created_at":"2015-03-19T13:26:09Z","updated_at":"2015-03-19T13:52:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b079e2fea8cfc0d1671e040093269847a7d97891","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/pulls/13/commits","review_comments_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/pulls/13/comments","review_comment_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/pulls/comments{/number}","comments_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/issues/13/comments","statuses_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/statuses/71061cb2ddb87706b6e8cd9c6643dddcbedf9b43","head":{"label":"UKHomeOffice:feature/validators-without-implicit-required","ref":"feature/validators-without-implicit-required","sha":"71061cb2ddb87706b6e8cd9c6643dddcbedf9b43","user":{"login":"UKHomeOffice","id":3778081,"avatar_url":"https://avatars.githubusercontent.com/u/3778081?v=3","gravatar_id":"","url":"https://api.github.com/users/UKHomeOffice","html_url":"https://github.com/UKHomeOffice","followers_url":"https://api.github.com/users/UKHomeOffice/followers","following_url":"https://api.github.com/users/UKHomeOffice/following{/other_user}","gists_url":"https://api.github.com/users/UKHomeOffice/gists{/gist_id}","starred_url":"https://api.github.com/users/UKHomeOffice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UKHomeOffice/subscriptions","organizations_url":"https://api.github.com/users/UKHomeOffice/orgs","repos_url":"https://api.github.com/users/UKHomeOffice/repos","events_url":"https://api.github.com/users/UKHomeOffice/events{/privacy}","received_events_url":"https://api.github.com/users/UKHomeOffice/received_events","type":"Organization","site_admin":false},"repo":{"id":30529402,"name":"passports-form-controller","full_name":"UKHomeOffice/passports-form-controller","owner":{"login":"UKHomeOffice","id":3778081,"avatar_url":"https://avatars.githubusercontent.com/u/3778081?v=3","gravatar_id":"","url":"https://api.github.com/users/UKHomeOffice","html_url":"https://github.com/UKHomeOffice","followers_url":"https://api.github.com/users/UKHomeOffice/followers","following_url":"https://api.github.com/users/UKHomeOffice/following{/other_user}","gists_url":"https://api.github.com/users/UKHomeOffice/gists{/gist_id}","starred_url":"https://api.github.com/users/UKHomeOffice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UKHomeOffice/subscriptions","organizations_url":"https://api.github.com/users/UKHomeOffice/orgs","repos_url":"https://api.github.com/users/UKHomeOffice/repos","events_url":"https://api.github.com/users/UKHomeOffice/events{/privacy}","received_events_url":"https://api.github.com/users/UKHomeOffice/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/UKHomeOffice/passports-form-controller","description":"","fork":false,"url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller","forks_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/forks","keys_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/keys{/key_id}","collaborators_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/teams","hooks_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/hooks","issue_events_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/issues/events{/number}","events_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/events","assignees_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/assignees{/user}","branches_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/branches{/branch}","tags_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/tags","blobs_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/git/refs{/sha}","trees_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/git/trees{/sha}","statuses_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/statuses/{sha}","languages_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/languages","stargazers_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/stargazers","contributors_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/contributors","subscribers_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/subscribers","subscription_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/subscription","commits_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/commits{/sha}","git_commits_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/git/commits{/sha}","comments_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/comments{/number}","issue_comment_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/issues/comments{/number}","contents_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/contents/{+path}","compare_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/compare/{base}...{head}","merges_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/merges","archive_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/downloads","issues_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/issues{/number}","pulls_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/pulls{/number}","milestones_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/milestones{/number}","notifications_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/labels{/name}","releases_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/releases{/id}","created_at":"2015-02-09T09:58:37Z","updated_at":"2015-03-19T10:29:36Z","pushed_at":"2015-03-19T13:33:47Z","git_url":"git://github.com/UKHomeOffice/passports-form-controller.git","ssh_url":"git@github.com:UKHomeOffice/passports-form-controller.git","clone_url":"https://github.com/UKHomeOffice/passports-form-controller.git","svn_url":"https://github.com/UKHomeOffice/passports-form-controller","homepage":null,"size":330,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"UKHomeOffice:master","ref":"master","sha":"d425223f43f927f5eaaee4f10e35998b981fd7ad","user":{"login":"UKHomeOffice","id":3778081,"avatar_url":"https://avatars.githubusercontent.com/u/3778081?v=3","gravatar_id":"","url":"https://api.github.com/users/UKHomeOffice","html_url":"https://github.com/UKHomeOffice","followers_url":"https://api.github.com/users/UKHomeOffice/followers","following_url":"https://api.github.com/users/UKHomeOffice/following{/other_user}","gists_url":"https://api.github.com/users/UKHomeOffice/gists{/gist_id}","starred_url":"https://api.github.com/users/UKHomeOffice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UKHomeOffice/subscriptions","organizations_url":"https://api.github.com/users/UKHomeOffice/orgs","repos_url":"https://api.github.com/users/UKHomeOffice/repos","events_url":"https://api.github.com/users/UKHomeOffice/events{/privacy}","received_events_url":"https://api.github.com/users/UKHomeOffice/received_events","type":"Organization","site_admin":false},"repo":{"id":30529402,"name":"passports-form-controller","full_name":"UKHomeOffice/passports-form-controller","owner":{"login":"UKHomeOffice","id":3778081,"avatar_url":"https://avatars.githubusercontent.com/u/3778081?v=3","gravatar_id":"","url":"https://api.github.com/users/UKHomeOffice","html_url":"https://github.com/UKHomeOffice","followers_url":"https://api.github.com/users/UKHomeOffice/followers","following_url":"https://api.github.com/users/UKHomeOffice/following{/other_user}","gists_url":"https://api.github.com/users/UKHomeOffice/gists{/gist_id}","starred_url":"https://api.github.com/users/UKHomeOffice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UKHomeOffice/subscriptions","organizations_url":"https://api.github.com/users/UKHomeOffice/orgs","repos_url":"https://api.github.com/users/UKHomeOffice/repos","events_url":"https://api.github.com/users/UKHomeOffice/events{/privacy}","received_events_url":"https://api.github.com/users/UKHomeOffice/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/UKHomeOffice/passports-form-controller","description":"","fork":false,"url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller","forks_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/forks","keys_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/keys{/key_id}","collaborators_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/teams","hooks_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/hooks","issue_events_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/issues/events{/number}","events_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/events","assignees_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/assignees{/user}","branches_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/branches{/branch}","tags_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/tags","blobs_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/git/refs{/sha}","trees_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/git/trees{/sha}","statuses_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/statuses/{sha}","languages_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/languages","stargazers_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/stargazers","contributors_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/contributors","subscribers_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/subscribers","subscription_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/subscription","commits_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/commits{/sha}","git_commits_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/git/commits{/sha}","comments_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/comments{/number}","issue_comment_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/issues/comments{/number}","contents_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/contents/{+path}","compare_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/compare/{base}...{head}","merges_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/merges","archive_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/downloads","issues_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/issues{/number}","pulls_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/pulls{/number}","milestones_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/milestones{/number}","notifications_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/labels{/name}","releases_url":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/releases{/id}","created_at":"2015-02-09T09:58:37Z","updated_at":"2015-03-19T10:29:36Z","pushed_at":"2015-03-19T13:33:47Z","git_url":"git://github.com/UKHomeOffice/passports-form-controller.git","ssh_url":"git@github.com:UKHomeOffice/passports-form-controller.git","clone_url":"https://github.com/UKHomeOffice/passports-form-controller.git","svn_url":"https://github.com/UKHomeOffice/passports-form-controller","homepage":null,"size":330,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/pulls/13"},"html":{"href":"https://github.com/UKHomeOffice/passports-form-controller/pull/13"},"issue":{"href":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/issues/13"},"comments":{"href":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/UKHomeOffice/passports-form-controller/statuses/71061cb2ddb87706b6e8cd9c6643dddcbedf9b43"}}}}