def is_valid_dict(to_test, required_args, optional_args, name, paradigm,
    strict=False):
    """
    Validates that a given dict has the expected arguments.

    :param to_test: (dict) the dictionary whose arguments are to be checked.

    :param required_args: (dict) A dictionary of expected arguments and the
    types of those arguments. Check will fail if all of these are not provided.

    :param optional_args: (dict) A dictionary of possible arguments and the
    types of those arguments. These will be type checked if provided, but are
    not necessary for a 'to_test' dict to be valid.

    :param name: (str) The name of this dict type. Used for debugging messages.

    :param paradigm: (str) The paradigm the tested dict is operating within.
    Only used for debugging messages.

    :param strict: (bool)[optional] Option to be strict about arguments. If
    True then any extra arguments that have been provided will fail. Default
    is False.

    :return: (Tuple(bool, str)) First value is boolean. True = to_test
    is valid, False = to_test is not valid. Second value is feedback
    string and will be empty if first value is True.
    """
    if not to_test:
        return False, 'A %s %s was not provided. ' % (paradigm, name)
    if not isinstance(to_test, dict):
        return (False, 
            'The %s %s was incorrectly formatted. Should be a dict, but %s is a %s'
             % (paradigm, name, to_test, type(to_test)))
    message = 'The %s %s %s had an incorrect structure, ' % (paradigm, name,
        to_test)
    for key, value in required_args.items():
        if key not in to_test:
            message += 'it is missing key %s. ' % key
            return False, message
        if not isinstance(to_test[key], value):
            message += (
                ' %s is expected to have type %s but actually has %s. ' % (
                to_test[key], value, type(to_test[key])))
            return False, message
    for key, value in optional_args.items():
        if key in to_test and not isinstance(to_test[key], value):
            message += (
                ' %s is expected to have type %s but actually has %s. ' % (
                to_test[key], value, type(to_test[key])))
            return False, message
    if strict:
        for key in to_test.keys():
            if key not in required_args and key not in optional_args:
                message += ' contains extra key %s' % key
                return False, message
    return True, ''
