Open Emailrus opened 8 years ago
You may use this method to validate the input data: https://github.com/ibireme/YYModel#data-validate-and-custom-transform
That would require validate every single field of json object, basically making a manual deserialization. Something that this library is trying to automate, isn't it?
Currently it seems, that there is no way to determine if conversion failed due to mapping error or because property in original json was null. For example:
Models
With this json conversion is fine, Result has an Error object. We can add assumption here, that if Error property is nil, then there were no errors on server.
Here server changed its API and now returns errors in array and conversion in old clients will always assign nil to that property, making clients assume, that there were no errors on server.
There is no safe mechanism in YYModel to determine why property is nil. My guess that having a method with
+ (instancetype)yy_modelWithJSON:(id)json error:(NSError **)pError
will help