Drew McCormack
Drew McCormack

Reputation: 3592

Can you validate an NSManagedObject without saving?

Is it possible to some how determine if an NSManagedObject is valid, without actually saving?

Seems like there should be an isValid function, or some way to request the NSManagedObjectContext to run validation for a particular object without actually saving.

The only workaround I can think of is to pull the object into a temporary child context, "touch" it so that it will be treated as updated, and then try to save the child context. But that seems quite barbaric.

Upvotes: 2

Views: 192

Answers (1)

Drew McCormack
Drew McCormack

Reputation: 3592

You can just call validateForInsert or validateForUpdate.

Upvotes: 1

Related Questions