from typing import Callable


def setup_valid_date_filter(valid_dates) -> Callable:
    """validator function for chunks of valid dates
    
    Args:
        valid_dates: list of [begin, end] in 'YYYYMMDD'
    
    Returns:
        a single argument ('YYYYMMDD-HHMMSS') validator function
    """
    def date_filter(e):
        datepair, f = e
        f_b, f_e = datepair
        #print(valid_dates, datepair, f_b, f_e)
        #print([(f_b >= valid[0] and f_e <= valid[1]) for valid in valid_dates])
        return any([(f_b[:-7] >= valid[0] and f_e[:-7] <= valid[1]) for valid in valid_dates])

    return date_filter