Giter Site home page Giter Site logo

Comments (5)

krzysztofzablocki avatar krzysztofzablocki commented on May 25, 2024

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.

BoneDesert avatar BoneDesert commented on May 25, 2024

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.

krzysztofzablocki avatar krzysztofzablocki commented on May 25, 2024

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.

BoneDesert avatar BoneDesert commented on May 25, 2024

doh! Of course it is. I'll definitely add the tests when I get a bit of time.

Thanks Krzysztof

from propertymapper.

krzysztofzablocki avatar krzysztofzablocki commented on May 25, 2024

👍 Send me a PR if you do, more tests are welcomed. Let me know if you need more help!

from propertymapper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.