dontWatchMyProfile
dontWatchMyProfile

Reputation: 46360

Is there any difference in the implementation of these three validation methods?

Core Data is calling these methods in certain situations:

- (BOOL)validateForInsert:(NSError **)outError;
- (BOOL)validateForUpdate:(NSError **)outError;
- (BOOL)validateForDelete:(NSError **)outError;

I wonder if they're doing anything different, or if they're essentially doing the exact same things.

As far as I know, these methods call the -validateValue:forKey:error: method once for every property.

The only difference I can imagine is in the .validateForDelete: method. I see no reason why to validate an object when it shall be deleted, except for applying delete rules, probably only in the case of the DENY rule.

Upvotes: 0

Views: 91

Answers (1)

Marcus S. Zarra
Marcus S. Zarra

Reputation: 46718

These are lifecycle validation methods. There are many situations that the question of validation differs depending on the object's state. For example:

  • Don't delete unless child X is nil
  • Don't insert unless value X is unique
  • Don't update unless child Y has been set

These methods give finer grain control over the integrity of the object hierarchy.

Upvotes: 1

Related Questions