def add_dict(field, dict_of_values):
    """
    Add a given dict of values to a given array field.
    """
    def transform(element):
        assert isinstance(element[field], dict), \
            "add_dict called on a non-dict object. type(element[%s]) = %s" % (field, type(element[field]))
        element[field].update(dict_of_values)

    return transform