krzysztofzablocki / PropertyMapper

Property mapping for Objective-C iOS apps.

Home Page:http://merowing.info

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

validationErrors array is always null

Dalein opened this issue · comments

I'm using:

 NSArray *validationErrors;
   BOOL isItemValid = [KZPropertyMapper mapValuesFrom:dic toInstance:self
                                          usingMapping:@{@"id" : KZProperty(Id),
                                                         @"name" : KZProperty(name),
                                                         @"has_sentiment" : KZProperty(tonality)
                                                         }
                                                errors:&validationErrors];

NSLog(@"validationErrors: %@", validationErrors);

And this I see in logs:

KZPropertyMapper: Ignoring mapping from name to name because type __NSSingleEntryDictionaryI does NOT match NSString
 KZPropertyMapper Error: Invalid condition not satisfying: isSameTypeObject
 arrErrors: (null)

What I'm doing wrong?

validationErrors are for validators https://github.com/krzysztofzablocki/PropertyMapper#validations, they happen before mapping is allowed, the errors you see in logs are mapping errors because the server data isn't matching the types you are asking it to map to

Fixed issue by adding
#import "KZPropertyDescriptor+Validators.h"

Not obvious that I have to do this.