'Validates that all items in the list are of the correct type.
Returns:
The validated list.
Raises:
BadValueError if the list has items are not instances of the
item_type given to the constructor.'

def validate_list_contents(self, value):

    if (self.item_type in (int, long)):
        item_type = (int, long)
    else:
        item_type = self.item_type
    for item in value:
        if (not isinstance(item, item_type)):
            if (item_type == (int, long)):
                raise BadValueError(('Items    in    the    %s    list    must    all    be    integers.' % self.name))
            else:
                raise BadValueError(('Items    in    the    %s    list    must    all    be    %s    instances' % (self.name, self.item_type.__name__)))
    return value
