{"action":"created","issue":{"url":"https://api.github.com/repos/nicolaiarocci/cerberus/issues/131","labels_url":"https://api.github.com/repos/nicolaiarocci/cerberus/issues/131/labels{/name}","comments_url":"https://api.github.com/repos/nicolaiarocci/cerberus/issues/131/comments","events_url":"https://api.github.com/repos/nicolaiarocci/cerberus/issues/131/events","html_url":"https://github.com/nicolaiarocci/cerberus/issues/131","id":96094411,"number":131,"title":"Proposal: Add `default`-normalization rule","user":{"login":"funkyfuture","id":2004405,"avatar_url":"https://avatars.githubusercontent.com/u/2004405?v=3","gravatar_id":"","url":"https://api.github.com/users/funkyfuture","html_url":"https://github.com/funkyfuture","followers_url":"https://api.github.com/users/funkyfuture/followers","following_url":"https://api.github.com/users/funkyfuture/following{/other_user}","gists_url":"https://api.github.com/users/funkyfuture/gists{/gist_id}","starred_url":"https://api.github.com/users/funkyfuture/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/funkyfuture/subscriptions","organizations_url":"https://api.github.com/users/funkyfuture/orgs","repos_url":"https://api.github.com/users/funkyfuture/repos","events_url":"https://api.github.com/users/funkyfuture/events{/privacy}","received_events_url":"https://api.github.com/users/funkyfuture/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-20T15:53:30Z","updated_at":"2015-07-22T07:16:29Z","closed_at":null,"body":"this is a follow-up of [this](https://github.com/nicolaiarocci/cerberus/issues/102#issuecomment-122241232).\r\n\r\nA `default`-rule would substitute any `None`-values, empty Mapping and Sequence-instances and numbers equal to zero for a given field with the provided constraint's value while a document is normalized. if the field isn't present at all, it will be added to the document with the constraint's value.\r\n\r\nthe `default`-constraint should be processed after coercing.\r\n\r\nexample:\r\n\r\n```python\r\n>>> schema = {'amount': {'default': 1}}\r\n>>> document = {'amount': None}\r\n>>> v.validated(document, schema)\r\n{'amount': 1}\r\n>>> document = {'model': 'The Robots'}\r\n>>> v.normalized(document, schema)\r\n{'model': 'The Robots', 'amount': 1}\r\n```"},"comment":{"url":"https://api.github.com/repos/nicolaiarocci/cerberus/issues/comments/123586833","html_url":"https://github.com/nicolaiarocci/cerberus/issues/131#issuecomment-123586833","issue_url":"https://api.github.com/repos/nicolaiarocci/cerberus/issues/131","id":123586833,"user":{"login":"nicolaiarocci","id":512968,"avatar_url":"https://avatars.githubusercontent.com/u/512968?v=3","gravatar_id":"","url":"https://api.github.com/users/nicolaiarocci","html_url":"https://github.com/nicolaiarocci","followers_url":"https://api.github.com/users/nicolaiarocci/followers","following_url":"https://api.github.com/users/nicolaiarocci/following{/other_user}","gists_url":"https://api.github.com/users/nicolaiarocci/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolaiarocci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolaiarocci/subscriptions","organizations_url":"https://api.github.com/users/nicolaiarocci/orgs","repos_url":"https://api.github.com/users/nicolaiarocci/repos","events_url":"https://api.github.com/users/nicolaiarocci/events{/privacy}","received_events_url":"https://api.github.com/users/nicolaiarocci/received_events","type":"User","site_admin":false},"created_at":"2015-07-22T07:16:29Z","updated_at":"2015-07-22T07:16:29Z","body":"Now that we also transform the incoming document, I guess that stuff like this is welcome. Actually, we implemented a `default` rule in Eve so I know it is useful :) :+1: "}}