You can detect if a PDF had a corrupt cross reference table, and was reported, see this post shows when and how.
Beyond that it is not generally possible to detect if a PDF is corrupt. To do so would require using every part of the file (rendering, text extraction, bookmarks, marked content, all layers, etc). For instance, the PDF might be correct, but a particular embedded font is malformed in some way, which isn't apparent until some part of the font is accessed (rendering or text selection).
If this doesn't help please let us know why detecting corrupt documents is important for you.