{"action":"opened","issue":{"url":"https://api.github.com/repos/alecthomas/voluptuous/issues/114","labels_url":"https://api.github.com/repos/alecthomas/voluptuous/issues/114/labels{/name}","comments_url":"https://api.github.com/repos/alecthomas/voluptuous/issues/114/comments","events_url":"https://api.github.com/repos/alecthomas/voluptuous/issues/114/events","html_url":"https://github.com/alecthomas/voluptuous/issues/114","id":59977753,"number":114,"title":"Library can report incorrect error messages","user":{"login":"svisser","id":723226,"avatar_url":"https://avatars.githubusercontent.com/u/723226?v=3","gravatar_id":"","url":"https://api.github.com/users/svisser","html_url":"https://github.com/svisser","followers_url":"https://api.github.com/users/svisser/followers","following_url":"https://api.github.com/users/svisser/following{/other_user}","gists_url":"https://api.github.com/users/svisser/gists{/gist_id}","starred_url":"https://api.github.com/users/svisser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svisser/subscriptions","organizations_url":"https://api.github.com/users/svisser/orgs","repos_url":"https://api.github.com/users/svisser/repos","events_url":"https://api.github.com/users/svisser/events{/privacy}","received_events_url":"https://api.github.com/users/svisser/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-05T16:36:59Z","updated_at":"2015-03-05T16:36:59Z","closed_at":null,"body":"Consider the following schema:\r\n\r\n```python\r\ns = Schema(\r\n    Any(\r\n        {Required('field'): In({'field_a', 'field_b'}), Required('value'): str},\r\n        {Required('field'): In({'field_c', 'field_d'}), Required('value'): int},\r\n    )\r\n)\r\n```\r\n\r\nIf I call `s({'field': 'field_a'})` I get:\r\n\r\n- `voluptuous.MultipleInvalid: required key not provided @ data['value']`\r\n\r\nIf I call `s({'field': 'field_c'})` I get:\r\n\r\n- `voluptuous.MultipleInvalid: value is not allowed for dictionary value @ data['field']`\r\n\r\nThe first of these makes sense, the second doesn't because `'field_c'` is a valid value for `'field'` in at least one alternative in `Any`.\r\n\r\nThis may be tricky to solve in the general case. When calling with ``s({'field': 'field_c'})` there are two errors for the first option (invalid \"field\" value and missing \"value\" field) and only one error for the second option (missing \"value\" field). So it may be possible to present the error message associated with the \"least bad\" match."}}