You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now I'm using + (id)modelOfClass:(Class)modelClass fromJSONDictionary:(NSDictionary *)JSONDictionary error:(NSError **)error to parse JSON to an object, but if some field is missing it would just assign nil to that property. Is there a way to validate required field and return an error, so I can handle it properly. Didn't see any validation in README.
Another question is when I use + (NSValueTransformer *)mtl_JSONArrayTransformerWithModelClass:(Class)modelClass if the data return isn't array it will failed from the NSAssert([dictionaries isKindOfClass:NSArray.class], @"Expected a array of dictionaries, got: %@", dictionaries); is there a way I can handle this before NSAssert happen, because this will crash the app in production if API is changed.
The text was updated successfully, but these errors were encountered:
Your second problem will be fixed 2.0 where this will simply be an decoding error. In the mean-time, I guess you can simply copy the current +mtl_JSONArrayTransformerWithModelClass: implementation and make it return something useful for you if its expectations are not met.
Please note that there will be additional changes to the behavior of said method 2.0.
Now I'm using
+ (id)modelOfClass:(Class)modelClass fromJSONDictionary:(NSDictionary *)JSONDictionary error:(NSError **)error
to parse JSON to an object, but if some field is missing it would just assign nil to that property. Is there a way to validate required field and return an error, so I can handle it properly. Didn't see any validation in README.Another question is when I use
+ (NSValueTransformer *)mtl_JSONArrayTransformerWithModelClass:(Class)modelClass
if the data return isn't array it will failed from theNSAssert([dictionaries isKindOfClass:NSArray.class], @"Expected a array of dictionaries, got: %@", dictionaries);
is there a way I can handle this before NSAssert happen, because this will crash the app in production if API is changed.The text was updated successfully, but these errors were encountered: