{"action":"closed","issue":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/5534","repository_url":"https://api.github.com/repos/Automattic/mongoose","labels_url":"https://api.github.com/repos/Automattic/mongoose/issues/5534/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/mongoose/issues/5534/comments","events_url":"https://api.github.com/repos/Automattic/mongoose/issues/5534/events","html_url":"https://github.com/Automattic/mongoose/issues/5534","id":248568487,"node_id":"MDU6SXNzdWUyNDg1Njg0ODc=","number":5534,"title":"Error messages cannot be overridden globally","user":{"login":"niftylettuce","id":523141,"node_id":"MDQ6VXNlcjUyMzE0MQ==","avatar_url":"https://avatars0.githubusercontent.com/u/523141?v=4","gravatar_id":"","url":"https://api.github.com/users/niftylettuce","html_url":"https://github.com/niftylettuce","followers_url":"https://api.github.com/users/niftylettuce/followers","following_url":"https://api.github.com/users/niftylettuce/following{/other_user}","gists_url":"https://api.github.com/users/niftylettuce/gists{/gist_id}","starred_url":"https://api.github.com/users/niftylettuce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/niftylettuce/subscriptions","organizations_url":"https://api.github.com/users/niftylettuce/orgs","repos_url":"https://api.github.com/users/niftylettuce/repos","events_url":"https://api.github.com/users/niftylettuce/events{/privacy}","received_events_url":"https://api.github.com/users/niftylettuce/received_events","type":"User","site_admin":false},"labels":[{"id":335758689,"node_id":"MDU6TGFiZWwzMzU3NTg2ODk=","url":"https://api.github.com/repos/Automattic/mongoose/labels/needs%20clarification","name":"needs clarification","color":"EB219B","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2017-08-08T00:35:28Z","updated_at":"2019-10-17T21:24:25Z","closed_at":"2019-10-17T21:24:25Z","author_association":"CONTRIBUTOR","body":"Similar to how we can specify `mongoose.Promise = global.Promise`, we should be able to specify error messages globally, such as putting `mongoose.Error.messages.general.required = \"The field {PATH} is required\"` anywhere in our codebase.\r\n\r\nSpecifying this in one file, and then defining a schema in another results in the schema defined having the standard built-in error messages here <https://github.com/Automattic/mongoose/blob/e659958fe80c5d03a7cb89a4e43804c1dd3ddda2/lib/error/messages.js>.\r\n\r\nAs mentioned on [this line](https://github.com/Automattic/mongoose/blob/e659958fe80c5d03a7cb89a4e43804c1dd3ddda2/lib/error/messages.js#L5), it is suggested you can define them \"globally\", however `global.mongoose` is never defined, only `global.db` is in Mongoose.\r\n\r\ncc @vkarpov15 "}}
{"actor":{"display_login":"vkarpov15"}}