Comments (5)
Right now If that method failed then all validators tests would since all validations paths use this method internally, but that's implementation detail and I agree we should test that method directly as well.
Any chance you could add few tests for that and send me PR? I've too much on my plate to add it now, but I'm thinking that tests like this should suffice considering tests already in validation suite:
- empty/non-existing array if there are no validations issues
- single error on 1 validation issue
- 4 errors on 4 issues
from propertymapper.
I've actually found this deffeciency as I have an issue implementing the call in my own app's test code and was looking for an example of use to see where I was going wrong. Its to do with the set-up of the NSArray __autoreleasing ** array
and how to operate on it. Xcode is freaking out at me:
- (BOOL)validateWeatherDataPresence {
self.weatherData = [NSArray new];
__autoreleasing NSArray **validationErrors;
BOOL result = [KZPropertyMapper mapValuesFrom:self.webSourcedData toInstance:self usingMapping:@{
@"data" : @{
@"weather": KZProperty(weatherData).isRequired()
}
} errors:validationErrors];
return result;
}
Xcode is reporting Argument in message expression is an uninitialised value ...
If I get it working (and get time) I'll certainly help.
from propertymapper.
that's not how you use output params in C based languages, also don't add __autoreleasing to variables, it's a description for a method interface not storage info on variable. Try this:
- (BOOL)validateWeatherDataPresence {
self.weatherData = [NSArray new];
NSArray *validationErrors;
BOOL result = [KZPropertyMapper mapValuesFrom:self.webSourcedData toInstance:self usingMapping:@{
@"data" : @{
@"weather": KZProperty(weatherData).isRequired()
}
} errors:&validationErrors];
return result;
}
For output params you use a pointer-to-pointer, more details are available here http://www.eskimo.com/~scs/cclass/int/sx8.html
PS. if you don't care about what errors are there you can call method that doesn't have errors, it will still work the same for your code since that BOOL return value is established as YES only if all validations succeded.
from propertymapper.
doh! Of course it is. I'll definitely add the tests when I get a bit of time.
Thanks Krzysztof
from propertymapper.
from propertymapper.
Related Issues (20)
- Assertion failure - which property? HOT 5
- Update CocoaPods with the latest commit HOT 2
- Asserts when receiving an NSArray instead of an NSDictionary HOT 3
- Crash when creating the date formatter
- Support for Swift HOT 1
- CocoaPods and 2.5.1? HOT 1
- KZCall on different object? HOT 4
- Doesn't work when there's a getter method defined HOT 2
- Support for compound property? HOT 4
- Support for NSEntityDescription instance HOT 2
- Nullify value for missing key/default value HOT 1
- ISO 8601 date format HOT 1
- Ability to Propagate Errors when using Custom Boxing / Call HOT 3
- No mapping if value from custom boxing is nil HOT 7
- Suppressing error messages HOT 4
- Crash when converting from number to NSDate HOT 2
- Crash when mapping null object to a primitive HOT 1
- validationErrors array is always null HOT 2
- Better warning message for missing Box custom methods HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from propertymapper.