def validate_table_name(table, empty_table=None):
    """
    Helper for validating a table object
    :param table: a sqlalchemy table object
    :param empty_table: the expected name of the table if table is None
    """

    if not getattr(table, "exists", False):
        empty_table = getattr(table, "name", empty_table)
        raise ValueError(f"No table named {empty_table}")

    return table