{"action":"created","comment":{"url":"https://api.github.com/repos/fzaninotto/Faker/pulls/comments/53784160","id":53784160,"diff_hunk":"@@ -0,0 +1,57 @@\n+<?php\n+\n+namespace Faker;\n+\n+/**\n+ * Proxy for other generators, to return only valid values. Works with\n+ * Faker\\Generator\\Base->valid()\n+ */\n+class ValidGenerator\n+{\n+    protected $generator;\n+    protected $validator;\n+    protected $maxRetries;\n+\n+    /**\n+     * @param Generator $generator\n+     */\n+    public function __construct(Generator $generator, $validator = null, $maxRetries = 10000)","path":"src/Faker/ValidGenerator.php","position":18,"original_position":18,"commit_id":"8c2c31823c594ac8dd8cc32af23edf7bc4e5ecb1","original_commit_id":"8c2c31823c594ac8dd8cc32af23edf7bc4e5ecb1","user":{"login":"EmanueleMinotto","id":417201,"avatar_url":"https://avatars.githubusercontent.com/u/417201?v=3","gravatar_id":"","url":"https://api.github.com/users/EmanueleMinotto","html_url":"https://github.com/EmanueleMinotto","followers_url":"https://api.github.com/users/EmanueleMinotto/followers","following_url":"https://api.github.com/users/EmanueleMinotto/following{/other_user}","gists_url":"https://api.github.com/users/EmanueleMinotto/gists{/gist_id}","starred_url":"https://api.github.com/users/EmanueleMinotto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EmanueleMinotto/subscriptions","organizations_url":"https://api.github.com/users/EmanueleMinotto/orgs","repos_url":"https://api.github.com/users/EmanueleMinotto/repos","events_url":"https://api.github.com/users/EmanueleMinotto/events{/privacy}","received_events_url":"https://api.github.com/users/EmanueleMinotto/received_events","type":"User","site_admin":false},"body":"What about forcing `$validator` to be a `\\Closure`?\r\nBecause without forcing it, functions not returning a boolean could be used.","created_at":"2016-02-23T14:14:29Z","updated_at":"2016-02-23T14:14:29Z","html_url":"https://github.com/fzaninotto/Faker/pull/836#discussion_r53784160","pull_request_url":"https://api.github.com/repos/fzaninotto/Faker/pulls/836","_links":{"self":{"href":"https://api.github.com/repos/fzaninotto/Faker/pulls/comments/53784160"},"html":{"href":"https://github.com/fzaninotto/Faker/pull/836#discussion_r53784160"},"pull_request":{"href":"https://api.github.com/repos/fzaninotto/Faker/pulls/836"}}},"pull_request":{"url":"https://api.github.com/repos/fzaninotto/Faker/pulls/836","id":60339389,"html_url":"https://github.com/fzaninotto/Faker/pull/836","diff_url":"https://github.com/fzaninotto/Faker/pull/836.diff","patch_url":"https://github.com/fzaninotto/Faker/pull/836.patch","issue_url":"https://api.github.com/repos/fzaninotto/Faker/issues/836","number":836,"state":"open","locked":false,"title":"[RFR] Introducting the valid() modifier","user":{"login":"fzaninotto","id":99944,"avatar_url":"https://avatars.githubusercontent.com/u/99944?v=3","gravatar_id":"","url":"https://api.github.com/users/fzaninotto","html_url":"https://github.com/fzaninotto","followers_url":"https://api.github.com/users/fzaninotto/followers","following_url":"https://api.github.com/users/fzaninotto/following{/other_user}","gists_url":"https://api.github.com/users/fzaninotto/gists{/gist_id}","starred_url":"https://api.github.com/users/fzaninotto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fzaninotto/subscriptions","organizations_url":"https://api.github.com/users/fzaninotto/orgs","repos_url":"https://api.github.com/users/fzaninotto/repos","events_url":"https://api.github.com/users/fzaninotto/events{/privacy}","received_events_url":"https://api.github.com/users/fzaninotto/received_events","type":"User","site_admin":false},"body":"```php\r\n<?php\r\n\r\n// valid() only accepts valid values according to the passed validator functions\r\n$values = array();\r\n$evenValidator = function($digit) {\r\n\treturn $digit % 2 === 0;\r\n};\r\nfor ($i=0; $i < 10; $i++) {\r\n\t$values []= $faker->valid($evenValidator)->randomDigit;\r\n}\r\nprint_r($values); // [0, 4, 8, 4, 2, 6, 0, 8, 8, 6]\r\n\r\n// just like unique(), valid() throws an overflow exception when it can't generate a valid value\r\n$values = array();\r\ntry {\r\n  $faker->valid($evenValidator)->randomElement(1, 3, 5, 7, 9);\r\n} catch (\\OverflowException $e) {\r\n  echo \"Can't pick an even number in that set!\";\r\n}\r\n```\r\n\r\nRefs #567 \r\n","created_at":"2016-02-23T13:29:59Z","updated_at":"2016-02-23T14:14:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9197d5010d0c5faf23f95677ff353d44b401c522","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/fzaninotto/Faker/pulls/836/commits","review_comments_url":"https://api.github.com/repos/fzaninotto/Faker/pulls/836/comments","review_comment_url":"https://api.github.com/repos/fzaninotto/Faker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fzaninotto/Faker/issues/836/comments","statuses_url":"https://api.github.com/repos/fzaninotto/Faker/statuses/8c2c31823c594ac8dd8cc32af23edf7bc4e5ecb1","head":{"label":"fzaninotto:valid_modifier","ref":"valid_modifier","sha":"8c2c31823c594ac8dd8cc32af23edf7bc4e5ecb1","user":{"login":"fzaninotto","id":99944,"avatar_url":"https://avatars.githubusercontent.com/u/99944?v=3","gravatar_id":"","url":"https://api.github.com/users/fzaninotto","html_url":"https://github.com/fzaninotto","followers_url":"https://api.github.com/users/fzaninotto/followers","following_url":"https://api.github.com/users/fzaninotto/following{/other_user}","gists_url":"https://api.github.com/users/fzaninotto/gists{/gist_id}","starred_url":"https://api.github.com/users/fzaninotto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fzaninotto/subscriptions","organizations_url":"https://api.github.com/users/fzaninotto/orgs","repos_url":"https://api.github.com/users/fzaninotto/repos","events_url":"https://api.github.com/users/fzaninotto/events{/privacy}","received_events_url":"https://api.github.com/users/fzaninotto/received_events","type":"User","site_admin":false},"repo":{"id":2579314,"name":"Faker","full_name":"fzaninotto/Faker","owner":{"login":"fzaninotto","id":99944,"avatar_url":"https://avatars.githubusercontent.com/u/99944?v=3","gravatar_id":"","url":"https://api.github.com/users/fzaninotto","html_url":"https://github.com/fzaninotto","followers_url":"https://api.github.com/users/fzaninotto/followers","following_url":"https://api.github.com/users/fzaninotto/following{/other_user}","gists_url":"https://api.github.com/users/fzaninotto/gists{/gist_id}","starred_url":"https://api.github.com/users/fzaninotto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fzaninotto/subscriptions","organizations_url":"https://api.github.com/users/fzaninotto/orgs","repos_url":"https://api.github.com/users/fzaninotto/repos","events_url":"https://api.github.com/users/fzaninotto/events{/privacy}","received_events_url":"https://api.github.com/users/fzaninotto/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fzaninotto/Faker","description":"Faker is a PHP library that generates fake data for you","fork":false,"url":"https://api.github.com/repos/fzaninotto/Faker","forks_url":"https://api.github.com/repos/fzaninotto/Faker/forks","keys_url":"https://api.github.com/repos/fzaninotto/Faker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fzaninotto/Faker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fzaninotto/Faker/teams","hooks_url":"https://api.github.com/repos/fzaninotto/Faker/hooks","issue_events_url":"https://api.github.com/repos/fzaninotto/Faker/issues/events{/number}","events_url":"https://api.github.com/repos/fzaninotto/Faker/events","assignees_url":"https://api.github.com/repos/fzaninotto/Faker/assignees{/user}","branches_url":"https://api.github.com/repos/fzaninotto/Faker/branches{/branch}","tags_url":"https://api.github.com/repos/fzaninotto/Faker/tags","blobs_url":"https://api.github.com/repos/fzaninotto/Faker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fzaninotto/Faker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fzaninotto/Faker/git/refs{/sha}","trees_url":"https://api.github.com/repos/fzaninotto/Faker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fzaninotto/Faker/statuses/{sha}","languages_url":"https://api.github.com/repos/fzaninotto/Faker/languages","stargazers_url":"https://api.github.com/repos/fzaninotto/Faker/stargazers","contributors_url":"https://api.github.com/repos/fzaninotto/Faker/contributors","subscribers_url":"https://api.github.com/repos/fzaninotto/Faker/subscribers","subscription_url":"https://api.github.com/repos/fzaninotto/Faker/subscription","commits_url":"https://api.github.com/repos/fzaninotto/Faker/commits{/sha}","git_commits_url":"https://api.github.com/repos/fzaninotto/Faker/git/commits{/sha}","comments_url":"https://api.github.com/repos/fzaninotto/Faker/comments{/number}","issue_comment_url":"https://api.github.com/repos/fzaninotto/Faker/issues/comments{/number}","contents_url":"https://api.github.com/repos/fzaninotto/Faker/contents/{+path}","compare_url":"https://api.github.com/repos/fzaninotto/Faker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fzaninotto/Faker/merges","archive_url":"https://api.github.com/repos/fzaninotto/Faker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fzaninotto/Faker/downloads","issues_url":"https://api.github.com/repos/fzaninotto/Faker/issues{/number}","pulls_url":"https://api.github.com/repos/fzaninotto/Faker/pulls{/number}","milestones_url":"https://api.github.com/repos/fzaninotto/Faker/milestones{/number}","notifications_url":"https://api.github.com/repos/fzaninotto/Faker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fzaninotto/Faker/labels{/name}","releases_url":"https://api.github.com/repos/fzaninotto/Faker/releases{/id}","deployments_url":"https://api.github.com/repos/fzaninotto/Faker/deployments","created_at":"2011-10-14T22:49:02Z","updated_at":"2016-02-23T12:29:35Z","pushed_at":"2016-02-23T13:29:59Z","git_url":"git://github.com/fzaninotto/Faker.git","ssh_url":"git@github.com:fzaninotto/Faker.git","clone_url":"https://github.com/fzaninotto/Faker.git","svn_url":"https://github.com/fzaninotto/Faker","homepage":"","size":8738,"stargazers_count":7877,"watchers_count":7877,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1189,"mirror_url":null,"open_issues_count":55,"forks":1189,"open_issues":55,"watchers":7877,"default_branch":"master"}},"base":{"label":"fzaninotto:master","ref":"master","sha":"2585edbef8b0e7a44c695217c35b16720203d8ee","user":{"login":"fzaninotto","id":99944,"avatar_url":"https://avatars.githubusercontent.com/u/99944?v=3","gravatar_id":"","url":"https://api.github.com/users/fzaninotto","html_url":"https://github.com/fzaninotto","followers_url":"https://api.github.com/users/fzaninotto/followers","following_url":"https://api.github.com/users/fzaninotto/following{/other_user}","gists_url":"https://api.github.com/users/fzaninotto/gists{/gist_id}","starred_url":"https://api.github.com/users/fzaninotto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fzaninotto/subscriptions","organizations_url":"https://api.github.com/users/fzaninotto/orgs","repos_url":"https://api.github.com/users/fzaninotto/repos","events_url":"https://api.github.com/users/fzaninotto/events{/privacy}","received_events_url":"https://api.github.com/users/fzaninotto/received_events","type":"User","site_admin":false},"repo":{"id":2579314,"name":"Faker","full_name":"fzaninotto/Faker","owner":{"login":"fzaninotto","id":99944,"avatar_url":"https://avatars.githubusercontent.com/u/99944?v=3","gravatar_id":"","url":"https://api.github.com/users/fzaninotto","html_url":"https://github.com/fzaninotto","followers_url":"https://api.github.com/users/fzaninotto/followers","following_url":"https://api.github.com/users/fzaninotto/following{/other_user}","gists_url":"https://api.github.com/users/fzaninotto/gists{/gist_id}","starred_url":"https://api.github.com/users/fzaninotto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fzaninotto/subscriptions","organizations_url":"https://api.github.com/users/fzaninotto/orgs","repos_url":"https://api.github.com/users/fzaninotto/repos","events_url":"https://api.github.com/users/fzaninotto/events{/privacy}","received_events_url":"https://api.github.com/users/fzaninotto/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fzaninotto/Faker","description":"Faker is a PHP library that generates fake data for you","fork":false,"url":"https://api.github.com/repos/fzaninotto/Faker","forks_url":"https://api.github.com/repos/fzaninotto/Faker/forks","keys_url":"https://api.github.com/repos/fzaninotto/Faker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fzaninotto/Faker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fzaninotto/Faker/teams","hooks_url":"https://api.github.com/repos/fzaninotto/Faker/hooks","issue_events_url":"https://api.github.com/repos/fzaninotto/Faker/issues/events{/number}","events_url":"https://api.github.com/repos/fzaninotto/Faker/events","assignees_url":"https://api.github.com/repos/fzaninotto/Faker/assignees{/user}","branches_url":"https://api.github.com/repos/fzaninotto/Faker/branches{/branch}","tags_url":"https://api.github.com/repos/fzaninotto/Faker/tags","blobs_url":"https://api.github.com/repos/fzaninotto/Faker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fzaninotto/Faker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fzaninotto/Faker/git/refs{/sha}","trees_url":"https://api.github.com/repos/fzaninotto/Faker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fzaninotto/Faker/statuses/{sha}","languages_url":"https://api.github.com/repos/fzaninotto/Faker/languages","stargazers_url":"https://api.github.com/repos/fzaninotto/Faker/stargazers","contributors_url":"https://api.github.com/repos/fzaninotto/Faker/contributors","subscribers_url":"https://api.github.com/repos/fzaninotto/Faker/subscribers","subscription_url":"https://api.github.com/repos/fzaninotto/Faker/subscription","commits_url":"https://api.github.com/repos/fzaninotto/Faker/commits{/sha}","git_commits_url":"https://api.github.com/repos/fzaninotto/Faker/git/commits{/sha}","comments_url":"https://api.github.com/repos/fzaninotto/Faker/comments{/number}","issue_comment_url":"https://api.github.com/repos/fzaninotto/Faker/issues/comments{/number}","contents_url":"https://api.github.com/repos/fzaninotto/Faker/contents/{+path}","compare_url":"https://api.github.com/repos/fzaninotto/Faker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fzaninotto/Faker/merges","archive_url":"https://api.github.com/repos/fzaninotto/Faker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fzaninotto/Faker/downloads","issues_url":"https://api.github.com/repos/fzaninotto/Faker/issues{/number}","pulls_url":"https://api.github.com/repos/fzaninotto/Faker/pulls{/number}","milestones_url":"https://api.github.com/repos/fzaninotto/Faker/milestones{/number}","notifications_url":"https://api.github.com/repos/fzaninotto/Faker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fzaninotto/Faker/labels{/name}","releases_url":"https://api.github.com/repos/fzaninotto/Faker/releases{/id}","deployments_url":"https://api.github.com/repos/fzaninotto/Faker/deployments","created_at":"2011-10-14T22:49:02Z","updated_at":"2016-02-23T12:29:35Z","pushed_at":"2016-02-23T13:29:59Z","git_url":"git://github.com/fzaninotto/Faker.git","ssh_url":"git@github.com:fzaninotto/Faker.git","clone_url":"https://github.com/fzaninotto/Faker.git","svn_url":"https://github.com/fzaninotto/Faker","homepage":"","size":8738,"stargazers_count":7877,"watchers_count":7877,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1189,"mirror_url":null,"open_issues_count":55,"forks":1189,"open_issues":55,"watchers":7877,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fzaninotto/Faker/pulls/836"},"html":{"href":"https://github.com/fzaninotto/Faker/pull/836"},"issue":{"href":"https://api.github.com/repos/fzaninotto/Faker/issues/836"},"comments":{"href":"https://api.github.com/repos/fzaninotto/Faker/issues/836/comments"},"review_comments":{"href":"https://api.github.com/repos/fzaninotto/Faker/pulls/836/comments"},"review_comment":{"href":"https://api.github.com/repos/fzaninotto/Faker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fzaninotto/Faker/pulls/836/commits"},"statuses":{"href":"https://api.github.com/repos/fzaninotto/Faker/statuses/8c2c31823c594ac8dd8cc32af23edf7bc4e5ecb1"}}}}