In the SuperDB application in More iPhone 3 Development, when we added multi-attribute validation, we inadvertently stopped the single-field validation on birthdate to stop working. In Hero.m, we have this at the end:
...
- (BOOL)validateForInsert:(NSError **)outError
- (BOOL) validateForUpdate:(NSError **)outError
@end
The method validateNameOrSecretIdentity: does our cross-field validation by looking at the two fields, but it doesn't do the rest of the validations, such as those from the data model, or those from custom validation methods. To handle those, we need a call to super.
The easiest way to handle this is to simply call super if validateNameOrSecretIdentity: returns NO. Typically, once we hit an error, we don't keep going. We could implement a more complex version that kept a running track of all errors and returned them, but I'm going to keep things simple here. Replace the code above with the following to get the rest of the validations working again:
...
- (BOOL)validateForInsert:(NSError **)outError
- (BOOL)validateForUpdate:(NSError **)outError
@end
I apologize for that!
0 nhận xét:
Post a Comment