def validate(self, instance, value):
        """Check the class of the container and validate each element

        This returns a copy of the container to prevent unwanted sharing of
        pointers.
        """
        if not self.coerce and not isinstance(value, self._class_container):
            self.error(instance, value)
        if self.coerce and not isinstance(value, CONTAINERS):
            value = [value]
        if not isinstance(value, self._class_container):
            out_class = self._class_container
        else:
            out_class = value.__class__
        out = []
        for val in value:
            try:
                out += [self.prop.validate(instance, val)]
            except ValueError:
                self.error(instance, val, extra='This item is invalid.')
        return out_class(out)
Check the class of the container and validate each element

        This returns a copy of the container to prevent unwanted sharing of
        pointers.