CodableWrappers
CodableWrappers copied to clipboard
Lossy object
Hello again! I'm the newbie from #37 so some of the considerations repeat.
Summary
I find the LossyCollections really useful, but something similar I needed to have was a lossy object, so that in case there is a decoding error, instead of the whole model throwing an error, I just get that property in null as if it wasn't even send in the first place. It may not be so obvious a case, but for example I needed the lossy object in the same cases as when I needed the lossy collections: this is not so relevant to fail everything for, I can ignore just that part and still show things that make sense to the user.
Questions
- I'm not sure I'm placing them in the correct file (
EmptyDefaults.swift). I think it's a Lossy thing, but the other file was called LossyCollections and this is not a collection, so it didn't make sense to me. And when I went to do the code, I ended up thinking of it as an "EmptyObject" which may not be completely the same idea as the empty defaults that are already there. So please let me know if you think another file is best. - [SAME QUESTION ABOUT THE PROJECT IN GENERAL] Also, could you tell me how to run this project? I wanted to contribute but I didn't see any Xcode Project or Workspace and it was a huge barrier to start. I decided to go for it none the less because I tested this code in my own project, but things like your tests, are a mystery I couldn't run. If you tell me I could add a Contributing section in the README with this useful information.
Hi @danielaRiesgo, with Swift Packages you can open the Package.swift and it opens Xcode with the Package as the project/workspace.
I think generally this case is intended to be solved by the properties being Optional.
E.g. in the example in the Tests:
private struct AnotherModel: Codable {
let required: Int?
}