{"action":"closed","issue":{"url":"https://api.github.com/repos/hapijs/joi/issues/766","labels_url":"https://api.github.com/repos/hapijs/joi/issues/766/labels{/name}","comments_url":"https://api.github.com/repos/hapijs/joi/issues/766/comments","events_url":"https://api.github.com/repos/hapijs/joi/issues/766/events","html_url":"https://github.com/hapijs/joi/issues/766","id":115474346,"number":766,"title":"When abortEarly set to false, don't return more than 1 error per key","user":{"login":"rightaway","id":3680078,"avatar_url":"https://avatars.githubusercontent.com/u/3680078?v=3","gravatar_id":"","url":"https://api.github.com/users/rightaway","html_url":"https://github.com/rightaway","followers_url":"https://api.github.com/users/rightaway/followers","following_url":"https://api.github.com/users/rightaway/following{/other_user}","gists_url":"https://api.github.com/users/rightaway/gists{/gist_id}","starred_url":"https://api.github.com/users/rightaway/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rightaway/subscriptions","organizations_url":"https://api.github.com/users/rightaway/orgs","repos_url":"https://api.github.com/users/rightaway/repos","events_url":"https://api.github.com/users/rightaway/events{/privacy}","received_events_url":"https://api.github.com/users/rightaway/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hapijs/joi/labels/request","name":"request","color":"c7def8"}],"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":1,"created_at":"2015-11-06T10:02:29Z","updated_at":"2015-11-06T10:28:03Z","closed_at":"2015-11-06T10:28:03Z","body":"If I've set a field to be both required and in email format, if I submit the form with an empty string I get this in `result.error`.\r\n\r\n```\r\n  \"details\": [\r\n    {\r\n      \"message\": \"\\\"email\\\" is not allowed to be empty\",\r\n      \"path\": \"email\",\r\n      \"type\": \"any.empty\",\r\n      \"context\": {\r\n        \"key\": \"email\"\r\n      }\r\n    },\r\n    {\r\n      \"message\": \"\\\"email\\\" must be a valid email\",\r\n      \"path\": \"email\",\r\n      \"type\": \"string.email\",\r\n      \"context\": {\r\n        \"value\": \"\",\r\n        \"key\": \"email\"\r\n      }\r\n    },\r\n```\r\n\r\nThis makes the client code (the code that determines what error message to display near the form input field) have to check if there are multiple errors per key, and determine which is the right one to put there. But in this case, `email must be a valid email` should not be displayed unless the field is not empty.\r\n\r\nSo if it is empty, it should display `email is not allowed to be empty`, and if it is not empty but not an email, then it should display `email must be a valid email`.\r\n\r\nI think it should be default behavior, but if it's not possible due to backward compatibility then an option like `oneErrorPerKey` should be made available to configure this."}}