{"action":"opened","issue":{"url":"https://api.github.com/repos/acornejo/jjv/issues/60","labels_url":"https://api.github.com/repos/acornejo/jjv/issues/60/labels{/name}","comments_url":"https://api.github.com/repos/acornejo/jjv/issues/60/comments","events_url":"https://api.github.com/repos/acornejo/jjv/issues/60/events","html_url":"https://github.com/acornejo/jjv/issues/60","id":123654159,"number":60,"title":"useDefault fails validation for nullable properties","user":{"login":"alexgoncharwix","id":8125260,"avatar_url":"https://avatars.githubusercontent.com/u/8125260?v=3","gravatar_id":"","url":"https://api.github.com/users/alexgoncharwix","html_url":"https://github.com/alexgoncharwix","followers_url":"https://api.github.com/users/alexgoncharwix/followers","following_url":"https://api.github.com/users/alexgoncharwix/following{/other_user}","gists_url":"https://api.github.com/users/alexgoncharwix/gists{/gist_id}","starred_url":"https://api.github.com/users/alexgoncharwix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexgoncharwix/subscriptions","organizations_url":"https://api.github.com/users/alexgoncharwix/orgs","repos_url":"https://api.github.com/users/alexgoncharwix/repos","events_url":"https://api.github.com/users/alexgoncharwix/events{/privacy}","received_events_url":"https://api.github.com/users/alexgoncharwix/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-23T12:43:24Z","updated_at":"2015-12-23T12:43:24Z","closed_at":null,"body":"```javascript\r\nSomeType: {\r\n       ....\r\n         nullableItem: {\r\n                    type: ['null', 'object'],\r\n                    properties: {\r\n                        shouldChangeUrl: {\r\n                            type: 'boolean',\r\n                            default: false\r\n                        }\r\n                    }\r\n                }\r\n       ....\r\n}\r\n```\r\nand then call validate with useDefault set to true\r\n```javascript\r\nvalidator.validate('SomeType', { nullableItem: null }, {useDefault: true});\r\n```\r\n\r\nExpected: validation succeeded.\r\nActual: validation failed.\r\n\r\nThis code throws an exception because options.useDefault == true:\r\n```javascript\r\nif (options.useDefault && hasProp && !malformed) {\r\n                for (p in schema.properties)\r\n                    if (schema.properties.hasOwnProperty(p) && !prop.hasOwnProperty(p) && schema.properties[p].hasOwnProperty('default'))\r\n                        prop[p] = schema.properties[p]['default'];\r\n            }\r\n```\r\n"}}