KiteJSONValidator
KiteJSONValidator copied to clipboard
Develop
Merge branch 'master' into develop
NSError as a result of validation/schema adding
@samskiter this patch is going to break backward compatibility. For the existing library users it may be like #define true false
.
Still, I agree that NSError should be returned by the affected method.
// AS IS
-(BOOL)validateJSONData:(NSData*)jsonData withSchemaData:(NSData*)schemaData;
// from the patch
-(NSError*)validateJSONData:(NSData*)jsonData withSchemaData:(NSData*)schemaData;
// My proposal
// follows Cocoa conventions
-(BOOL)validateJSONData:(NSData*)jsonData
withSchemaData:(NSData*)schemaData
error:(NSError**)outError;
@dodikk that's a great catch! thank you. My head is in Java mode at the minute and I forgot about the auto cast. also, this is actually the way i prefer to return errors if any - more consistent with apple's APIs and other libraries
@nut-code-monkey sorry for another delay on this PR.
@samskiter , I think, these days I'll finally get a chance (in terms of time) to add your validator to my project. Eventually, I'll adopt these changes and remaster the API in the Cocoa way so that you'll get a patch from me.
P.S. @samskiter , I guess, this one is no longer relevant and can be closed. https://github.com/samskiter/KiteJSONValidator/pull/9
@samskiter spent some of my leisure time trying to make the API follow the cocoa style https://github.com/dodikk/KiteJSONValidator/commit/7db8daee50fc3488d80c1e157ebfe57c5a235cb1
I can't afford spending so much time copy-pasting the if (NULL != outError)
thing and structuring "return" statements. So, I'm giving up for now. Sorry.
It would be a lot easier if I could use NSAssert(NULL != outError)
rather than if
statements. It would makes the changes so much more simple.
Such policy makes sense since it will be a lot harder to ignore validation errors. @samskiter , what do you think?
Hi @dodikk thanks very much for your efforts. this is on my TODO list to sort out properly. It does look a little smelly that we have to have a lot of checks agains NULL (this should probably be nil
by the way). so I will have to take a closer look.
It does look a little smelly that we have to have a lot of checks agains NULL (this should probably be nil by the way).
That's how out parameters are done in "plain old C". And yes, apple allows NULL errors in their own API.
this should probably be nil by the way
No, it should not. NSError*
(one star) and NSError**
(two stars) are two completely different types. http://nshipster.com/nil/