Document "xyz" could not be saved. Multiple validation errors occured

document synonym
types of document
examples of documents
documents download
document antonym
document app
categories of documents
document in a sentence

Apologies if this is a bit vague, but that's half of the problem.

I have a document based core data app that I am working on, it is doing what it's told while running and doesn't generate any errors. But when the user saves the document, the document pops up a 'The document "xyz" could not be saved as "xyz". Multiple validation errors occurred' alert.

My question is - where do you start looking to fix / debug this? As the program does not fall over in the debugger I have no stack trace etc. Is this liable to be a faulty Entity relationship, or no data being saved in a non-optional Attribute of an Entity or... Is there a way to tell exactly what is failing validation?

Any suggestions of the best way to proceed greatly appreciated.

Related to this, what / how is the best method to catch such an error in the future so it doesn't get as far as the user.

Many Thanks

Validation errors suggest that the problem lays with validation predicates that are applied when the document is saved. In turn that means that some data you've attempted to save is of the wrong type or the wrong values.

If you capture the error return from the save operation, the userInfo dictionary should contain details about the failures.

Document, Examples of document in a Sentence. Noun It is important to keep all of your financial documents in a safe place. An important classified document has been  eTour.com is the newest place to search, delivering top results from across the web. Content updated daily for automating word documents.

Ok, as TechZen suggested, capture the error from the save operation. Add the following to MyDocument.m

 - (NSError *)willPresentError:(NSError *)error {

    // Only deal with Core Data Errors
    if (!([[error domain] isEqualToString:NSCocoaErrorDomain])) {
        return error;
    }
    NSInteger errorCode = [error code];
    if ((errorCode < NSValidationErrorMinimum) || (errorCode > NSValidationErrorMaximum)) {
        return error;
    }

    // If there is only 1 error, let the usual alert display it
    if (errorCode != NSValidationMultipleErrorsError) {
        return error;
    }   

    // Get the errors. NSValidationMultipleErrorsError - the errors are in an array in the userInfo dictionary for key NSDetailedErrorsKey
    NSArray *detailedErrors = [[error userInfo] objectForKey:NSDetailedErrorsKey];
    NSUInteger errorCount = [detailedErrors count];
    NSMutableString *errorString = [NSMutableString stringWithFormat:@"There are %lu validation errors:-", errorCount];
    for (int i = 0; i < errorCount; i++) {
        [errorString appendFormat:@"%@\n",
            [[detailedErrors objectAtIndex:i] localizedDescription]];
    }

    // Create a new error with the new userInfo and return it
    NSMutableDictionary *newUserInfo = [NSMutableDictionary dictionaryWithDictionary:[error userInfo]];
    [newUserInfo setObject:errorString forKey:NSLocalizedDescriptionKey];
    NSError *newError = [NSError errorWithDomain:[error domain] code:[error code] userInfo:newUserInfo];
    return newError;
}

Note if there are 100 errors then you will get an alert with 100 items in which is not the best, but this is a good starting point for dealing with errors on save.

Document, A document is a written, drawn, presented, or memorialized representation of thought, often the manifestation of non-fictional, as well as fictional, content. Find digital document management on TheAnswerHub.com. TheAnswerHub is a top destination for finding answers online. Browse our content today!

Google Docs, Create, edit and collaborate with others on documents from your Android phone or tablet with the Google Docs app. With Docs you can: - Create new documents​  Easy to find your documents! Find my documents folder how to now!

If you set any regex validation in the core data property, such error will appear too. Maybe you can check on this area. I got this error by this way.

Sign-in, Not your computer? Use Guest mode to sign in privately. Learn more. Next. Create account. ‪Afrikaans‬. ‪azərbaycan‬. ‪català‬. ‪Čeština‬. ‪Dansk‬. ‪Deutsch‬. ‪eesti‬  document: [noun] proof, evidence. an original or official paper relied on as the basis, proof, or support of something. something (such as a photograph or a recording) that serves as evidence or proof.

Document, Depending on the document's type (e.g. HTML, XML, SVG, …), a larger API is available: HTML documents, served with the "text/html" content type  Create and edit web-based documents, spreadsheets, and presentations. Store documents online and access them from any computer.

Document, Document definition, a written or printed paper furnishing information or evidence​, as a passport, deed, bill of sale, or bill of lading; a legal or official paper. Create a new document and edit it with others at the same time — from your computer, phone or tablet. Free with a Google account.

Document Journal, document meaning: 1. a paper or set of papers with written or printed information, especially of an official type…. Learn more. A document is a written, drawn, presented, or memorialized representation of thought, often the manifestation of non-fictional, as well as fictional, content.The word originates from the Latin Documentum, which denotes a "teaching" or "lesson": the verb doceō denotes "to teach".

Comments
  • I take it this is a Core Data document based Cocoa app?
  • Thanks. I had just worked out where capture the error when I saw your reply. I will mark your answer as correct but I will also post my solution so I can flesh it out with some code in case someone else needs it. Google is very light on this issue, the only entries I could find were people complaining that commercial software they had bought was giving this error! Shame on those companies.