{"action":"created","issue":{"url":"https://api.github.com/repos/hapijs/joi/issues/866","repository_url":"https://api.github.com/repos/hapijs/joi","labels_url":"https://api.github.com/repos/hapijs/joi/issues/866/labels{/name}","comments_url":"https://api.github.com/repos/hapijs/joi/issues/866/comments","events_url":"https://api.github.com/repos/hapijs/joi/issues/866/events","html_url":"https://github.com/hapijs/joi/issues/866","id":148178173,"number":866,"title":"cannot validate \"undefined\" properly","user":{"login":"tyrchen","id":473888,"avatar_url":"https://avatars.githubusercontent.com/u/473888?v=3","gravatar_id":"","url":"https://api.github.com/users/tyrchen","html_url":"https://github.com/tyrchen","followers_url":"https://api.github.com/users/tyrchen/followers","following_url":"https://api.github.com/users/tyrchen/following{/other_user}","gists_url":"https://api.github.com/users/tyrchen/gists{/gist_id}","starred_url":"https://api.github.com/users/tyrchen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tyrchen/subscriptions","organizations_url":"https://api.github.com/users/tyrchen/orgs","repos_url":"https://api.github.com/users/tyrchen/repos","events_url":"https://api.github.com/users/tyrchen/events{/privacy}","received_events_url":"https://api.github.com/users/tyrchen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hapijs/joi/labels/question","name":"question","color":"d4c5f9"}],"state":"closed","locked":false,"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":null,"comments":3,"created_at":"2016-04-13T20:42:35Z","updated_at":"2016-04-14T14:12:59Z","closed_at":"2016-04-14T08:09:39Z","body":"#### Context\r\n\r\n* *node version*: any (4.3.0)\r\n* *joi version*: 7.3.0\r\n* *environment* (node, browser): node\r\n* *used with* (hapi, standalone, ...): standalone\r\n\r\n#### What are you trying to achieve or the steps to reproduce ?\r\n\r\nIssue is easy reproducible:\r\n\r\n```bash\r\n> joi.validate(undefined, joi.object({key1: joi.string().required()}))\r\n{ error: null, value: undefined }\r\n> joi.validate(null, joi.object({key1: joi.string().required()}))\r\n{ error:\r\n   { [ValidationError: \"value\" must be an object]\r\n     isJoi: true,\r\n     name: 'ValidationError',\r\n     details: [ [Object] ],\r\n     _object: null,\r\n     annotate: [Function] },\r\n  value: null }\r\n> joi.validate({}, joi.object({key1: joi.string().required()}))\r\n{ error:\r\n   { [ValidationError: child \"key1\" fails because [\"key1\" is required]]\r\n     isJoi: true,\r\n     name: 'ValidationError',\r\n     details: [ [Object] ],\r\n     _object: {},\r\n     annotate: [Function] },\r\n  value: {} }\r\n```\r\n\r\n#### Which result you had ?\r\n\r\n``{ error: null, value: undefined }``.\r\n\r\n#### What did you expect ?\r\n\r\nfor a variable which hold ``undefined``, it should not pass validation. joi should give an error in the result."},"comment":{"url":"https://api.github.com/repos/hapijs/joi/issues/comments/209963103","html_url":"https://github.com/hapijs/joi/issues/866#issuecomment-209963103","issue_url":"https://api.github.com/repos/hapijs/joi/issues/866","id":209963103,"user":{"login":"tyrchen","id":473888,"avatar_url":"https://avatars.githubusercontent.com/u/473888?v=3","gravatar_id":"","url":"https://api.github.com/users/tyrchen","html_url":"https://github.com/tyrchen","followers_url":"https://api.github.com/users/tyrchen/followers","following_url":"https://api.github.com/users/tyrchen/following{/other_user}","gists_url":"https://api.github.com/users/tyrchen/gists{/gist_id}","starred_url":"https://api.github.com/users/tyrchen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tyrchen/subscriptions","organizations_url":"https://api.github.com/users/tyrchen/orgs","repos_url":"https://api.github.com/users/tyrchen/repos","events_url":"https://api.github.com/users/tyrchen/events{/privacy}","received_events_url":"https://api.github.com/users/tyrchen/received_events","type":"User","site_admin":false},"created_at":"2016-04-14T14:12:59Z","updated_at":"2016-04-14T14:12:59Z","body":"oh, I see. Thanks for explanation. :+1: "}}