from pathlib import Path
import zipfile


def _invalid_zipfile(filepath):
    """
    Checks both the zip-container and the files within.
    Returns None if valid, else some error-string
    """
    if Path(filepath) and Path(filepath).exists():
        # Test if the filepath points to a .zip-file with a valid container
        try:
            zfile = zipfile.ZipFile(filepath, "r")
        except zipfile.BadZipfile:
            return "%s not a valid zip-container" % filepath

        # Test the content of each file in the zip-archive
        return zfile.testzip()
    else:
        return "%s not a valid filepath" % filepath