{"action":"created","issue":{"url":"https://api.github.com/repos/dry-rb/dry-validation/issues/91","repository_url":"https://api.github.com/repos/dry-rb/dry-validation","labels_url":"https://api.github.com/repos/dry-rb/dry-validation/issues/91/labels{/name}","comments_url":"https://api.github.com/repos/dry-rb/dry-validation/issues/91/comments","events_url":"https://api.github.com/repos/dry-rb/dry-validation/issues/91/events","html_url":"https://github.com/dry-rb/dry-validation/pull/91","id":145637588,"number":91,"title":"Validator explodes when not given a hash when expecting one.","user":{"login":"kwando","id":891566,"avatar_url":"https://avatars.githubusercontent.com/u/891566?v=3","gravatar_id":"","url":"https://api.github.com/users/kwando","html_url":"https://github.com/kwando","followers_url":"https://api.github.com/users/kwando/followers","following_url":"https://api.github.com/users/kwando/following{/other_user}","gists_url":"https://api.github.com/users/kwando/gists{/gist_id}","starred_url":"https://api.github.com/users/kwando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kwando/subscriptions","organizations_url":"https://api.github.com/users/kwando/orgs","repos_url":"https://api.github.com/users/kwando/repos","events_url":"https://api.github.com/users/kwando/events{/privacy}","received_events_url":"https://api.github.com/users/kwando/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-04T09:59:33Z","updated_at":"2016-04-04T10:33:18Z","closed_at":"2016-04-04T10:17:50Z","pull_request":{"url":"https://api.github.com/repos/dry-rb/dry-validation/pulls/91","html_url":"https://github.com/dry-rb/dry-validation/pull/91","diff_url":"https://github.com/dry-rb/dry-validation/pull/91.diff","patch_url":"https://github.com/dry-rb/dry-validation/pull/91.patch"},"body":"A failing test which should probably work.\r\n\r\nI've not added any expectations."},"comment":{"url":"https://api.github.com/repos/dry-rb/dry-validation/issues/comments/205234317","html_url":"https://github.com/dry-rb/dry-validation/pull/91#issuecomment-205234317","issue_url":"https://api.github.com/repos/dry-rb/dry-validation/issues/91","id":205234317,"user":{"login":"solnic","id":1066,"avatar_url":"https://avatars.githubusercontent.com/u/1066?v=3","gravatar_id":"","url":"https://api.github.com/users/solnic","html_url":"https://github.com/solnic","followers_url":"https://api.github.com/users/solnic/followers","following_url":"https://api.github.com/users/solnic/following{/other_user}","gists_url":"https://api.github.com/users/solnic/gists{/gist_id}","starred_url":"https://api.github.com/users/solnic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solnic/subscriptions","organizations_url":"https://api.github.com/users/solnic/orgs","repos_url":"https://api.github.com/users/solnic/repos","events_url":"https://api.github.com/users/solnic/events{/privacy}","received_events_url":"https://api.github.com/users/solnic/received_events","type":"User","site_admin":false},"created_at":"2016-04-04T10:33:18Z","updated_at":"2016-04-04T10:33:18Z","body":"It's an equivalent of a situation where your code calls `user.valid?` where user is nil or something. It's your responsibility to not let that happen. So ie if you use dry-v against params from a form submission, then you can assume it will be a hash, but if you want to be paranoid you can just do `hash? do .. end` inside your schema, this would protect you from unexpected requests; however, I would suggest to split validation into 2 schemas, one that checks input structure, and return 'invalid request' if it's structure is malformed, and another one to actually apply your business rules. This is a very flexible system, so use it in a way that makes sense for your use cases. I'm especially interested in providing good support for 2-step validation like I just described, it's still being discussed (and I'm not the only one who thinks it's a good idea)."}}