{"action":"created","comment":{"url":"https://api.github.com/repos/hapijs/joi/pulls/comments/87876767","pull_request_review_id":8470151,"id":87876767,"diff_hunk":"@@ -91,19 +91,30 @@ internals.String = class extends Any {\n         });\n     }\n \n-    regex(pattern, name) {\n+    regex(pattern, config) {\n \n         Hoek.assert(pattern instanceof RegExp, 'pattern must be a RegExp');\n \n         pattern = new RegExp(pattern.source, pattern.ignoreCase ? 'i' : undefined);         // Future version should break this and forbid unsupported regex flags\n \n-        return this._test('regex', pattern, function (value, state, options) {\n+        const patternIsInvalidated = (typeof config === 'object' && Hoek.reach(config, 'invalidate'));\n+        const testName = patternIsInvalidated ? 'invalidatedRegex' : 'regex';\n \n-            if (pattern.test(value)) {\n+        return this._test(testName, pattern, function (value, state, options) {","path":"lib/string.js","position":16,"original_position":16,"commit_id":"c5f95af4cfdf347e1fc7aabe797fae48327c5f02","original_commit_id":"c5f95af4cfdf347e1fc7aabe797fae48327c5f02","user":{"login":"Marsup","id":796194,"avatar_url":"https://avatars.githubusercontent.com/u/796194?v=3","gravatar_id":"","url":"https://api.github.com/users/Marsup","html_url":"https://github.com/Marsup","followers_url":"https://api.github.com/users/Marsup/followers","following_url":"https://api.github.com/users/Marsup/following{/other_user}","gists_url":"https://api.github.com/users/Marsup/gists{/gist_id}","starred_url":"https://api.github.com/users/Marsup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Marsup/subscriptions","organizations_url":"https://api.github.com/users/Marsup/orgs","repos_url":"https://api.github.com/users/Marsup/repos","events_url":"https://api.github.com/users/Marsup/events{/privacy}","received_events_url":"https://api.github.com/users/Marsup/received_events","type":"User","site_admin":false},"body":"It will automatically if you do.","created_at":"2016-11-14T19:41:02Z","updated_at":"2016-11-14T19:41:02Z","html_url":"https://github.com/hapijs/joi/pull/1035#discussion_r87876767","pull_request_url":"https://api.github.com/repos/hapijs/joi/pulls/1035","_links":{"self":{"href":"https://api.github.com/repos/hapijs/joi/pulls/comments/87876767"},"html":{"href":"https://github.com/hapijs/joi/pull/1035#discussion_r87876767"},"pull_request":{"href":"https://api.github.com/repos/hapijs/joi/pulls/1035"}}},"pull_request":{"url":"https://api.github.com/repos/hapijs/joi/pulls/1035","id":93605690,"html_url":"https://github.com/hapijs/joi/pull/1035","diff_url":"https://github.com/hapijs/joi/pull/1035.diff","patch_url":"https://github.com/hapijs/joi/pull/1035.patch","issue_url":"https://api.github.com/repos/hapijs/joi/issues/1035","number":1035,"state":"open","locked":false,"title":"Implement String.regex \"invalidate\" configuration","user":{"login":"WesTyler","id":12154939,"avatar_url":"https://avatars.githubusercontent.com/u/12154939?v=3","gravatar_id":"","url":"https://api.github.com/users/WesTyler","html_url":"https://github.com/WesTyler","followers_url":"https://api.github.com/users/WesTyler/followers","following_url":"https://api.github.com/users/WesTyler/following{/other_user}","gists_url":"https://api.github.com/users/WesTyler/gists{/gist_id}","starred_url":"https://api.github.com/users/WesTyler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WesTyler/subscriptions","organizations_url":"https://api.github.com/users/WesTyler/orgs","repos_url":"https://api.github.com/users/WesTyler/repos","events_url":"https://api.github.com/users/WesTyler/events{/privacy}","received_events_url":"https://api.github.com/users/WesTyler/received_events","type":"User","site_admin":false},"body":"Per discussions in #1033 and #1020, refactored `string().regex(pattern, [name])` to support `string().regex(pattern, [name | config])` as follows:\r\n\r\n1. If `name` is a string it behaves as currently implemented. No change.\r\n2. If `config` is an object, it supports the following properties:\r\n  - `name`: {string}, behaves as currently implemented.\r\n  - `invalidate`: {boolean}, defaults to `false` behavior; if `true`, disallows the provided regex pattern.\r\n\r\nUsage: \r\n```Javascript\r\nconst schema = Joi.string().regex(/[a-z]/, {\r\n    name      : 'lowercase',\r\n    invalidate: true\r\n});\r\n\r\nschema.validate('bad', (err, value) => {\r\n    if (err) {\r\n        // ValidationError: \"value\" with value \"bad\" matches the invalidated lowercase pattern\r\n    }\r\n});\r\nschema.validate('BAD', (err, value) => {\r\n    if (err) {} // err === null\r\n});\r\n\r\nschema.describe();\r\n/*\r\n{\r\n  type: 'string',\r\n  invalids: [ '' ],\r\n  rules: [ { name: 'invalidatedRegex', arg: /[a-z]/ } ] \r\n}\r\n*/ \r\n```","created_at":"2016-11-14T17:02:43Z","updated_at":"2016-11-14T19:41:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b78ce0d185d13324bac4564c6c8583dc3db186c2","assignee":{"login":"Marsup","id":796194,"avatar_url":"https://avatars.githubusercontent.com/u/796194?v=3","gravatar_id":"","url":"https://api.github.com/users/Marsup","html_url":"https://github.com/Marsup","followers_url":"https://api.github.com/users/Marsup/followers","following_url":"https://api.github.com/users/Marsup/following{/other_user}","gists_url":"https://api.github.com/users/Marsup/gists{/gist_id}","starred_url":"https://api.github.com/users/Marsup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Marsup/subscriptions","organizations_url":"https://api.github.com/users/Marsup/orgs","repos_url":"https://api.github.com/users/Marsup/repos","events_url":"https://api.github.com/users/Marsup/events{/privacy}","received_events_url":"https://api.github.com/users/Marsup/received_events","type":"User","site_admin":false},"assignees":[{"login":"Marsup","id":796194,"avatar_url":"https://avatars.githubusercontent.com/u/796194?v=3","gravatar_id":"","url":"https://api.github.com/users/Marsup","html_url":"https://github.com/Marsup","followers_url":"https://api.github.com/users/Marsup/followers","following_url":"https://api.github.com/users/Marsup/following{/other_user}","gists_url":"https://api.github.com/users/Marsup/gists{/gist_id}","starred_url":"https://api.github.com/users/Marsup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Marsup/subscriptions","organizations_url":"https://api.github.com/users/Marsup/orgs","repos_url":"https://api.github.com/users/Marsup/repos","events_url":"https://api.github.com/users/Marsup/events{/privacy}","received_events_url":"https://api.github.com/users/Marsup/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/hapijs/joi/pulls/1035/commits","review_comments_url":"https://api.github.com/repos/hapijs/joi/pulls/1035/comments","review_comment_url":"https://api.github.com/repos/hapijs/joi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hapijs/joi/issues/1035/comments","statuses_url":"https://api.github.com/repos/hapijs/joi/statuses/c5f95af4cfdf347e1fc7aabe797fae48327c5f02","head":{"label":"WesTyler:master","ref":"master","sha":"c5f95af4cfdf347e1fc7aabe797fae48327c5f02","user":{"login":"WesTyler","id":12154939,"avatar_url":"https://avatars.githubusercontent.com/u/12154939?v=3","gravatar_id":"","url":"https://api.github.com/users/WesTyler","html_url":"https://github.com/WesTyler","followers_url":"https://api.github.com/users/WesTyler/followers","following_url":"https://api.github.com/users/WesTyler/following{/other_user}","gists_url":"https://api.github.com/users/WesTyler/gists{/gist_id}","starred_url":"https://api.github.com/users/WesTyler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WesTyler/subscriptions","organizations_url":"https://api.github.com/users/WesTyler/orgs","repos_url":"https://api.github.com/users/WesTyler/repos","events_url":"https://api.github.com/users/WesTyler/events{/privacy}","received_events_url":"https://api.github.com/users/WesTyler/received_events","type":"User","site_admin":false},"repo":{"id":69921156,"name":"joi","full_name":"WesTyler/joi","owner":{"login":"WesTyler","id":12154939,"avatar_url":"https://avatars.githubusercontent.com/u/12154939?v=3","gravatar_id":"","url":"https://api.github.com/users/WesTyler","html_url":"https://github.com/WesTyler","followers_url":"https://api.github.com/users/WesTyler/followers","following_url":"https://api.github.com/users/WesTyler/following{/other_user}","gists_url":"https://api.github.com/users/WesTyler/gists{/gist_id}","starred_url":"https://api.github.com/users/WesTyler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WesTyler/subscriptions","organizations_url":"https://api.github.com/users/WesTyler/orgs","repos_url":"https://api.github.com/users/WesTyler/repos","events_url":"https://api.github.com/users/WesTyler/events{/privacy}","received_events_url":"https://api.github.com/users/WesTyler/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/WesTyler/joi","description":"Object schema validation","fork":true,"url":"https://api.github.com/repos/WesTyler/joi","forks_url":"https://api.github.com/repos/WesTyler/joi/forks","keys_url":"https://api.github.com/repos/WesTyler/joi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WesTyler/joi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WesTyler/joi/teams","hooks_url":"https://api.github.com/repos/WesTyler/joi/hooks","issue_events_url":"https://api.github.com/repos/WesTyler/joi/issues/events{/number}","events_url":"https://api.github.com/repos/WesTyler/joi/events","assignees_url":"https://api.github.com/repos/WesTyler/joi/assignees{/user}","branches_url":"https://api.github.com/repos/WesTyler/joi/branches{/branch}","tags_url":"https://api.github.com/repos/WesTyler/joi/tags","blobs_url":"https://api.github.com/repos/WesTyler/joi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WesTyler/joi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WesTyler/joi/git/refs{/sha}","trees_url":"https://api.github.com/repos/WesTyler/joi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WesTyler/joi/statuses/{sha}","languages_url":"https://api.github.com/repos/WesTyler/joi/languages","stargazers_url":"https://api.github.com/repos/WesTyler/joi/stargazers","contributors_url":"https://api.github.com/repos/WesTyler/joi/contributors","subscribers_url":"https://api.github.com/repos/WesTyler/joi/subscribers","subscription_url":"https://api.github.com/repos/WesTyler/joi/subscription","commits_url":"https://api.github.com/repos/WesTyler/joi/commits{/sha}","git_commits_url":"https://api.github.com/repos/WesTyler/joi/git/commits{/sha}","comments_url":"https://api.github.com/repos/WesTyler/joi/comments{/number}","issue_comment_url":"https://api.github.com/repos/WesTyler/joi/issues/comments{/number}","contents_url":"https://api.github.com/repos/WesTyler/joi/contents/{+path}","compare_url":"https://api.github.com/repos/WesTyler/joi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WesTyler/joi/merges","archive_url":"https://api.github.com/repos/WesTyler/joi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WesTyler/joi/downloads","issues_url":"https://api.github.com/repos/WesTyler/joi/issues{/number}","pulls_url":"https://api.github.com/repos/WesTyler/joi/pulls{/number}","milestones_url":"https://api.github.com/repos/WesTyler/joi/milestones{/number}","notifications_url":"https://api.github.com/repos/WesTyler/joi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WesTyler/joi/labels{/name}","releases_url":"https://api.github.com/repos/WesTyler/joi/releases{/id}","deployments_url":"https://api.github.com/repos/WesTyler/joi/deployments","created_at":"2016-10-04T00:03:33Z","updated_at":"2016-10-04T00:03:35Z","pushed_at":"2016-11-14T17:12:20Z","git_url":"git://github.com/WesTyler/joi.git","ssh_url":"git@github.com:WesTyler/joi.git","clone_url":"https://github.com/WesTyler/joi.git","svn_url":"https://github.com/WesTyler/joi","homepage":null,"size":2659,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"hapijs:master","ref":"master","sha":"e657a5ab89b48b563409859015f3b1f42501784a","user":{"login":"hapijs","id":3774533,"avatar_url":"https://avatars.githubusercontent.com/u/3774533?v=3","gravatar_id":"","url":"https://api.github.com/users/hapijs","html_url":"https://github.com/hapijs","followers_url":"https://api.github.com/users/hapijs/followers","following_url":"https://api.github.com/users/hapijs/following{/other_user}","gists_url":"https://api.github.com/users/hapijs/gists{/gist_id}","starred_url":"https://api.github.com/users/hapijs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hapijs/subscriptions","organizations_url":"https://api.github.com/users/hapijs/orgs","repos_url":"https://api.github.com/users/hapijs/repos","events_url":"https://api.github.com/users/hapijs/events{/privacy}","received_events_url":"https://api.github.com/users/hapijs/received_events","type":"Organization","site_admin":false},"repo":{"id":5830987,"name":"joi","full_name":"hapijs/joi","owner":{"login":"hapijs","id":3774533,"avatar_url":"https://avatars.githubusercontent.com/u/3774533?v=3","gravatar_id":"","url":"https://api.github.com/users/hapijs","html_url":"https://github.com/hapijs","followers_url":"https://api.github.com/users/hapijs/followers","following_url":"https://api.github.com/users/hapijs/following{/other_user}","gists_url":"https://api.github.com/users/hapijs/gists{/gist_id}","starred_url":"https://api.github.com/users/hapijs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hapijs/subscriptions","organizations_url":"https://api.github.com/users/hapijs/orgs","repos_url":"https://api.github.com/users/hapijs/repos","events_url":"https://api.github.com/users/hapijs/events{/privacy}","received_events_url":"https://api.github.com/users/hapijs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hapijs/joi","description":"Object schema validation","fork":false,"url":"https://api.github.com/repos/hapijs/joi","forks_url":"https://api.github.com/repos/hapijs/joi/forks","keys_url":"https://api.github.com/repos/hapijs/joi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hapijs/joi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hapijs/joi/teams","hooks_url":"https://api.github.com/repos/hapijs/joi/hooks","issue_events_url":"https://api.github.com/repos/hapijs/joi/issues/events{/number}","events_url":"https://api.github.com/repos/hapijs/joi/events","assignees_url":"https://api.github.com/repos/hapijs/joi/assignees{/user}","branches_url":"https://api.github.com/repos/hapijs/joi/branches{/branch}","tags_url":"https://api.github.com/repos/hapijs/joi/tags","blobs_url":"https://api.github.com/repos/hapijs/joi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hapijs/joi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hapijs/joi/git/refs{/sha}","trees_url":"https://api.github.com/repos/hapijs/joi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hapijs/joi/statuses/{sha}","languages_url":"https://api.github.com/repos/hapijs/joi/languages","stargazers_url":"https://api.github.com/repos/hapijs/joi/stargazers","contributors_url":"https://api.github.com/repos/hapijs/joi/contributors","subscribers_url":"https://api.github.com/repos/hapijs/joi/subscribers","subscription_url":"https://api.github.com/repos/hapijs/joi/subscription","commits_url":"https://api.github.com/repos/hapijs/joi/commits{/sha}","git_commits_url":"https://api.github.com/repos/hapijs/joi/git/commits{/sha}","comments_url":"https://api.github.com/repos/hapijs/joi/comments{/number}","issue_comment_url":"https://api.github.com/repos/hapijs/joi/issues/comments{/number}","contents_url":"https://api.github.com/repos/hapijs/joi/contents/{+path}","compare_url":"https://api.github.com/repos/hapijs/joi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hapijs/joi/merges","archive_url":"https://api.github.com/repos/hapijs/joi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hapijs/joi/downloads","issues_url":"https://api.github.com/repos/hapijs/joi/issues{/number}","pulls_url":"https://api.github.com/repos/hapijs/joi/pulls{/number}","milestones_url":"https://api.github.com/repos/hapijs/joi/milestones{/number}","notifications_url":"https://api.github.com/repos/hapijs/joi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hapijs/joi/labels{/name}","releases_url":"https://api.github.com/repos/hapijs/joi/releases{/id}","deployments_url":"https://api.github.com/repos/hapijs/joi/deployments","created_at":"2012-09-16T16:38:06Z","updated_at":"2016-11-14T17:29:18Z","pushed_at":"2016-11-14T17:12:21Z","git_url":"git://github.com/hapijs/joi.git","ssh_url":"git@github.com:hapijs/joi.git","clone_url":"https://github.com/hapijs/joi.git","svn_url":"https://github.com/hapijs/joi","homepage":null,"size":4215,"stargazers_count":3811,"watchers_count":3811,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":396,"mirror_url":null,"open_issues_count":51,"forks":396,"open_issues":51,"watchers":3811,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hapijs/joi/pulls/1035"},"html":{"href":"https://github.com/hapijs/joi/pull/1035"},"issue":{"href":"https://api.github.com/repos/hapijs/joi/issues/1035"},"comments":{"href":"https://api.github.com/repos/hapijs/joi/issues/1035/comments"},"review_comments":{"href":"https://api.github.com/repos/hapijs/joi/pulls/1035/comments"},"review_comment":{"href":"https://api.github.com/repos/hapijs/joi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hapijs/joi/pulls/1035/commits"},"statuses":{"href":"https://api.github.com/repos/hapijs/joi/statuses/c5f95af4cfdf347e1fc7aabe797fae48327c5f02"}}}}
{"actor":{"display_login":"Marsup"}}