def METHOD_NAME(value, field_name, expected, is_array=False):
    if not is_array:
        if not isinstance(value, expected):
            raise TypeError("Expected %s of type %s, got %s" % (field_name, expected, type(value).__name__))
        return
    if not all(isinstance(x, expected) for x in value):
        raise TypeError(
            "Expected %s of type list[%s], got %s" % (
                field_name,
                expected,
                ", ".join(set(type(x).__name__ for x in value)),
            )
        )