I have a data model where one of the string attributes has both a min
and max length validation requirement. At run time though, only the
max length constraint seems to exist. Violating the min length
constraint doesn't cause validation failures, whether using
-validateForInsert: or -validateValue:forKey:error: For example:

        NSString *tooShortName = @"a";
        NSError *validationError = nil;
        [category validateValue:&tooShortName forKey:@"name" 
error:&validationError];

At this point validationError is still nil. Continuing:

        [category setValue:tooShortName forKey:@"name"];
        [category validateForInsert:&validationError];

...still nil.

I suspected that the data model GUI might be lying to me so I looked
at the model file directly (glad it's XML) and found this for the
attribute:

<attribute name="name" attributeType="String" minValueString="10"
maxValueString="100" syncable="YES"/>

So, both constraints are in the model file. They don't both get loaded
at run time though:

(gdb) po [[[[category entity] attributesByName] objectForKey:@"name"]
validationPredicates]
<__NSArrayM 0x897bcd0>(
length <= 100
)

I tried creating a new project to test this and got the same thing
immediately. Is there some additional step I've missed?

I'm using Xcode 4.2.1 on Mac OS X 10.7.2; results are the same in the
simulator and on an iPhone 4s running iOS 5.0.1.

-- 
Tom Harrington
atomicb...@gmail.com
AIM: atomicbird1
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to