{"action":"created","comment":{"url":"https://api.github.com/repos/hapijs/joi/pulls/comments/49023248","id":49023248,"diff_hunk":"@@ -304,6 +316,83 @@ describe('date', () => {\n             });\n         });\n \n+        describe('timestamp()', () => {\n+\n+            it('validates javascript timestamp', (done) => {\n+\n+                const now = new Date();\n+                const milliseconds = now.getTime();\n+\n+                Joi.date().timestamp().validate(milliseconds, (err, value) => {\n+\n+                    expect(err).to.not.exist();\n+                    expect(value).to.deep.equal(now);\n+                });\n+                Joi.date().timestamp('javascript').validate(milliseconds, (err, value) => {\n+\n+                    expect(err).to.not.exist();\n+                    expect(value).to.deep.equal(now);\n+                });\n+                done();\n+            });\n+\n+            it('validates unix timestamp', (done) => {\n+\n+                const now = new Date();\n+                const seconds = now.getTime() / 1000;\n+\n+                Joi.date().timestamp('unix').validate(seconds, (err, value) => {\n+\n+                    expect(err).to.not.exist();\n+                    expect(value).to.deep.equal(now);\n+                    done();\n+                });\n+            });\n+\n+            it('validates timestamps with decimals', (done) => {\n+\n+                Helper.validate(Joi.date().timestamp(), [\n+                    [new Date().getTime().toFixed(4), true]\n+                ]);\n+                Helper.validate(Joi.date().timestamp('javascript'), [\n+                    [new Date().getTime().toFixed(4), true]\n+                ]);\n+                Helper.validate(Joi.date().timestamp('unix'), [\n+                    [(new Date().getTime() / 1000).toFixed(4), true]\n+                ]);\n+                done();\n+            });\n+\n+            it('fails with not allowed type', (done) => {\n+\n+                expect(() => {\n+\n+                    Joi.date().timestamp('not allowed');\n+                }).to.throw(Error, new RegExp('\"type\" must be one of'));\n+                done();\n+            });\n+\n+            it('validates timestamps with a friendly error message', (done) => {\n+\n+                const timestamp = { timestamp: Joi.date().timestamp() };\n+                const timestampJavascript = { timestamp: Joi.date().timestamp('javascript') };\n+                const timestampUnix = { timestamp: Joi.date().timestamp('unix') };\n+                Joi.compile(timestamp).validate({ timestamp: 'not a timestamp' }, (err, value) => {\n+\n+                    expect(err.message).to.contain('must be a valid timestamp');\n+                });\n+                Joi.compile(timestampJavascript).validate({ timestamp: 'not a timestamp' }, (err, value) => {\n+\n+                    expect(err.message).to.contain('must be a valid timestamp');\n+                });\n+                Joi.compile(timestampUnix).validate({ timestamp: 'not a timestamp' }, (err, value) => {\n+\n+                    expect(err.message).to.contain('must be a valid timestamp');\n+                });\n+                done();\n+            });\n+        });\n+","path":"test/date.js","position":106,"original_position":106,"commit_id":"78e750b70eaf4194beb693435e46fc98d59714ef","original_commit_id":"78e750b70eaf4194beb693435e46fc98d59714ef","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":"Missing a test asserting correct toggling of the flag (`Joi.date().timestamp().timestamp('unix')`)","created_at":"2016-01-06T23:13:35Z","updated_at":"2016-01-06T23:13:35Z","html_url":"https://github.com/hapijs/joi/pull/791#discussion_r49023248","pull_request_url":"https://api.github.com/repos/hapijs/joi/pulls/791","_links":{"self":{"href":"https://api.github.com/repos/hapijs/joi/pulls/comments/49023248"},"html":{"href":"https://github.com/hapijs/joi/pull/791#discussion_r49023248"},"pull_request":{"href":"https://api.github.com/repos/hapijs/joi/pulls/791"}}},"pull_request":{"url":"https://api.github.com/repos/hapijs/joi/pulls/791","id":54878895,"html_url":"https://github.com/hapijs/joi/pull/791","diff_url":"https://github.com/hapijs/joi/pull/791.diff","patch_url":"https://github.com/hapijs/joi/pull/791.patch","issue_url":"https://api.github.com/repos/hapijs/joi/issues/791","number":791,"state":"open","locked":false,"title":"Date enhancements and support for Unix Timestamps","user":{"login":"galenandrew","id":796368,"avatar_url":"https://avatars.githubusercontent.com/u/796368?v=3","gravatar_id":"","url":"https://api.github.com/users/galenandrew","html_url":"https://github.com/galenandrew","followers_url":"https://api.github.com/users/galenandrew/followers","following_url":"https://api.github.com/users/galenandrew/following{/other_user}","gists_url":"https://api.github.com/users/galenandrew/gists{/gist_id}","starred_url":"https://api.github.com/users/galenandrew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/galenandrew/subscriptions","organizations_url":"https://api.github.com/users/galenandrew/orgs","repos_url":"https://api.github.com/users/galenandrew/repos","events_url":"https://api.github.com/users/galenandrew/events{/privacy}","received_events_url":"https://api.github.com/users/galenandrew/received_events","type":"User","site_admin":false},"body":"_Revised_\r\n--\r\n\r\nThis PR includes the following changes:\r\n- Support for decimals in `date()` validation\r\n- New constraint for `date.timestamp()` that supports both _javascript_ and _unix_ timestamps\r\n- Updated Tests, API documentation, and added date example\r\n\r\n\r\n_Note: Because javascript timestamps are millisecond-based and unix timestamps are second-based, the `timestamp()` constraint accepts an optional `type` parameter to ensure proper date conversion for the given input value._\r\n\r\ncloses #789","created_at":"2015-12-31T20:16:52Z","updated_at":"2016-01-06T23:13:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2817811a2ed77257c16427ea8321e218fca2876f","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},"milestone":{"url":"https://api.github.com/repos/hapijs/joi/milestones/59","html_url":"https://github.com/hapijs/joi/milestones/7.2.0","labels_url":"https://api.github.com/repos/hapijs/joi/milestones/59/labels","id":1475693,"number":59,"title":"7.2.0","description":null,"creator":{"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},"open_issues":2,"closed_issues":1,"state":"open","created_at":"2015-12-28T09:53:09Z","updated_at":"2016-01-06T23:01:43Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/hapijs/joi/pulls/791/commits","review_comments_url":"https://api.github.com/repos/hapijs/joi/pulls/791/comments","review_comment_url":"https://api.github.com/repos/hapijs/joi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hapijs/joi/issues/791/comments","statuses_url":"https://api.github.com/repos/hapijs/joi/statuses/78e750b70eaf4194beb693435e46fc98d59714ef","head":{"label":"galenandrew:timestamps","ref":"timestamps","sha":"78e750b70eaf4194beb693435e46fc98d59714ef","user":{"login":"galenandrew","id":796368,"avatar_url":"https://avatars.githubusercontent.com/u/796368?v=3","gravatar_id":"","url":"https://api.github.com/users/galenandrew","html_url":"https://github.com/galenandrew","followers_url":"https://api.github.com/users/galenandrew/followers","following_url":"https://api.github.com/users/galenandrew/following{/other_user}","gists_url":"https://api.github.com/users/galenandrew/gists{/gist_id}","starred_url":"https://api.github.com/users/galenandrew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/galenandrew/subscriptions","organizations_url":"https://api.github.com/users/galenandrew/orgs","repos_url":"https://api.github.com/users/galenandrew/repos","events_url":"https://api.github.com/users/galenandrew/events{/privacy}","received_events_url":"https://api.github.com/users/galenandrew/received_events","type":"User","site_admin":false},"repo":{"id":48763993,"name":"joi","full_name":"galenandrew/joi","owner":{"login":"galenandrew","id":796368,"avatar_url":"https://avatars.githubusercontent.com/u/796368?v=3","gravatar_id":"","url":"https://api.github.com/users/galenandrew","html_url":"https://github.com/galenandrew","followers_url":"https://api.github.com/users/galenandrew/followers","following_url":"https://api.github.com/users/galenandrew/following{/other_user}","gists_url":"https://api.github.com/users/galenandrew/gists{/gist_id}","starred_url":"https://api.github.com/users/galenandrew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/galenandrew/subscriptions","organizations_url":"https://api.github.com/users/galenandrew/orgs","repos_url":"https://api.github.com/users/galenandrew/repos","events_url":"https://api.github.com/users/galenandrew/events{/privacy}","received_events_url":"https://api.github.com/users/galenandrew/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/galenandrew/joi","description":"Object schema validation","fork":true,"url":"https://api.github.com/repos/galenandrew/joi","forks_url":"https://api.github.com/repos/galenandrew/joi/forks","keys_url":"https://api.github.com/repos/galenandrew/joi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/galenandrew/joi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/galenandrew/joi/teams","hooks_url":"https://api.github.com/repos/galenandrew/joi/hooks","issue_events_url":"https://api.github.com/repos/galenandrew/joi/issues/events{/number}","events_url":"https://api.github.com/repos/galenandrew/joi/events","assignees_url":"https://api.github.com/repos/galenandrew/joi/assignees{/user}","branches_url":"https://api.github.com/repos/galenandrew/joi/branches{/branch}","tags_url":"https://api.github.com/repos/galenandrew/joi/tags","blobs_url":"https://api.github.com/repos/galenandrew/joi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/galenandrew/joi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/galenandrew/joi/git/refs{/sha}","trees_url":"https://api.github.com/repos/galenandrew/joi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/galenandrew/joi/statuses/{sha}","languages_url":"https://api.github.com/repos/galenandrew/joi/languages","stargazers_url":"https://api.github.com/repos/galenandrew/joi/stargazers","contributors_url":"https://api.github.com/repos/galenandrew/joi/contributors","subscribers_url":"https://api.github.com/repos/galenandrew/joi/subscribers","subscription_url":"https://api.github.com/repos/galenandrew/joi/subscription","commits_url":"https://api.github.com/repos/galenandrew/joi/commits{/sha}","git_commits_url":"https://api.github.com/repos/galenandrew/joi/git/commits{/sha}","comments_url":"https://api.github.com/repos/galenandrew/joi/comments{/number}","issue_comment_url":"https://api.github.com/repos/galenandrew/joi/issues/comments{/number}","contents_url":"https://api.github.com/repos/galenandrew/joi/contents/{+path}","compare_url":"https://api.github.com/repos/galenandrew/joi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/galenandrew/joi/merges","archive_url":"https://api.github.com/repos/galenandrew/joi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/galenandrew/joi/downloads","issues_url":"https://api.github.com/repos/galenandrew/joi/issues{/number}","pulls_url":"https://api.github.com/repos/galenandrew/joi/pulls{/number}","milestones_url":"https://api.github.com/repos/galenandrew/joi/milestones{/number}","notifications_url":"https://api.github.com/repos/galenandrew/joi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/galenandrew/joi/labels{/name}","releases_url":"https://api.github.com/repos/galenandrew/joi/releases{/id}","created_at":"2015-12-29T19:36:53Z","updated_at":"2015-12-29T19:36:54Z","pushed_at":"2016-01-04T22:16:39Z","git_url":"git://github.com/galenandrew/joi.git","ssh_url":"git@github.com:galenandrew/joi.git","clone_url":"https://github.com/galenandrew/joi.git","svn_url":"https://github.com/galenandrew/joi","homepage":null,"size":2010,"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":"93ca39f65e05de1e9dd0043bbf970aebb6e347c6","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}","created_at":"2012-09-16T16:38:06Z","updated_at":"2016-01-06T16:10:12Z","pushed_at":"2016-01-04T22:16:40Z","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":2495,"stargazers_count":2066,"watchers_count":2066,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":264,"mirror_url":null,"open_issues_count":20,"forks":264,"open_issues":20,"watchers":2066,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hapijs/joi/pulls/791"},"html":{"href":"https://github.com/hapijs/joi/pull/791"},"issue":{"href":"https://api.github.com/repos/hapijs/joi/issues/791"},"comments":{"href":"https://api.github.com/repos/hapijs/joi/issues/791/comments"},"review_comments":{"href":"https://api.github.com/repos/hapijs/joi/pulls/791/comments"},"review_comment":{"href":"https://api.github.com/repos/hapijs/joi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hapijs/joi/pulls/791/commits"},"statuses":{"href":"https://api.github.com/repos/hapijs/joi/statuses/78e750b70eaf4194beb693435e46fc98d59714ef"}}}}