{"action":"created","issue":{"url":"https://api.github.com/repos/mobxjs/serializr/issues/90","repository_url":"https://api.github.com/repos/mobxjs/serializr","labels_url":"https://api.github.com/repos/mobxjs/serializr/issues/90/labels{/name}","comments_url":"https://api.github.com/repos/mobxjs/serializr/issues/90/comments","events_url":"https://api.github.com/repos/mobxjs/serializr/issues/90/events","html_url":"https://github.com/mobxjs/serializr/pull/90","id":362893104,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE3NDc5OTQz","number":90,"title":"lifecycle handlers for advanced deserialization and error handling","user":{"login":"evoye","id":1121003,"node_id":"MDQ6VXNlcjExMjEwMDM=","avatar_url":"https://avatars1.githubusercontent.com/u/1121003?v=4","gravatar_id":"","url":"https://api.github.com/users/evoye","html_url":"https://github.com/evoye","followers_url":"https://api.github.com/users/evoye/followers","following_url":"https://api.github.com/users/evoye/following{/other_user}","gists_url":"https://api.github.com/users/evoye/gists{/gist_id}","starred_url":"https://api.github.com/users/evoye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evoye/subscriptions","organizations_url":"https://api.github.com/users/evoye/orgs","repos_url":"https://api.github.com/users/evoye/repos","events_url":"https://api.github.com/users/evoye/events{/privacy}","received_events_url":"https://api.github.com/users/evoye/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-22T21:42:26Z","updated_at":"2018-09-22T21:56:18Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/mobxjs/serializr/pulls/90","html_url":"https://github.com/mobxjs/serializr/pull/90","diff_url":"https://github.com/mobxjs/serializr/pull/90.diff","patch_url":"https://github.com/mobxjs/serializr/pull/90.patch"},"body":"# Problem\r\nThe current deserialization process did not allow sufficient flexibility to react to errors or schema migrations in the source JSON file during the deserialization process.\r\nE.g. it was not possible, to remove invalid items from the source data while in the deserialization process. In static structures it might be easy to analyse the complete JSON before. However, in complex structures - especially polymorphic ones - the business logic for the structure should only be in the model and not be replicated. This required the validation and correction logic to be also placed in the model during the deserialization process.\r\n\r\n# Solution\r\nThe current solution allows to specify two lifecycle handlers:\r\n- beforeDeserialize\r\n- afterDeserialize\r\n\r\nThose handlers get called in each deserialization step, where specified. It is possible to assign different handlers at each step to specify different logic.\r\n\r\nExamples for use cases are:\r\n- react to changes in field names, e.g. due to schema migration (i.e. only one-directional changes that cannot be dealt with by alias operators)\r\n- react to errors in deserialization and retry with corrected value\r\n- remove invalid items e.g. in arrays or maps\r\n\r\nThe handlers have been provided for all relevant propSchemes and should also work when dealing with reference resolution and / or async deserialization.\r\n\r\nThere were also minor improvements:\r\n- added debugging parameter to npm options\r\n- added cancelDeserialize (for async requests that get stuck, e.g. in case of unresolved waiting references)\r\n- added capability to deserialize arrays with empty entries\r\n\r\n\r\n# Next Steps\r\n\r\n- Please have a look at the changes, especially the respective test case in ts.ts. It is a bit more complex, but should handle all the above mentioned claims.\r\n- Give me some feedback (API design etc.)\r\n- I've commented out the tests for mapAsArray, the propSchema behaved not in the way I expected, maybe I misunderstood it or it needs a fix...\r\n- After we went through the discussion and the change design is accepted, I will polish everything and finalize the docs.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/mobxjs/serializr/issues/comments/423776211","html_url":"https://github.com/mobxjs/serializr/pull/90#issuecomment-423776211","issue_url":"https://api.github.com/repos/mobxjs/serializr/issues/90","id":423776211,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMzc3NjIxMQ==","user":{"login":"coveralls","id":2354108,"node_id":"MDQ6VXNlcjIzNTQxMDg=","avatar_url":"https://avatars1.githubusercontent.com/u/2354108?v=4","gravatar_id":"","url":"https://api.github.com/users/coveralls","html_url":"https://github.com/coveralls","followers_url":"https://api.github.com/users/coveralls/followers","following_url":"https://api.github.com/users/coveralls/following{/other_user}","gists_url":"https://api.github.com/users/coveralls/gists{/gist_id}","starred_url":"https://api.github.com/users/coveralls/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coveralls/subscriptions","organizations_url":"https://api.github.com/users/coveralls/orgs","repos_url":"https://api.github.com/users/coveralls/repos","events_url":"https://api.github.com/users/coveralls/events{/privacy}","received_events_url":"https://api.github.com/users/coveralls/received_events","type":"User","site_admin":false},"created_at":"2018-09-22T21:56:18Z","updated_at":"2018-09-22T21:56:18Z","author_association":"NONE","body":"\n[![Coverage Status](https://coveralls.io/builds/19141245/badge)](https://coveralls.io/builds/19141245)\n\nCoverage decreased (-0.7%) to 91.482% when pulling **f98dbe5620d491616f9e854f73a921e92f4a7b86 on evoye:master** into **c85a6376fdc535ace2661e5a35686e1928d53901 on mobxjs:master**.\n"}}
{"actor":{"display_login":"coveralls"}}