def validate_value(self, value):
        """Check whether value is of allowed type."""
        value_type = type(value)

        ### if value is string, it doesn't validate if it is
        ### empty or if 'string_when_single' attribute is
        ### False

        if value_type is str:

            if not value:

                raise ValueError("if 'value' is of 'str' type, it" " must not be empty")

            elif not self.string_when_single:

                raise ValueError(
                    "if 'string_when_single' is"
                    " False, 'value' must always"
                    " be a tuple"
                )

        ### if it is a tuple , more conditions need to be
        ### checked

        elif value_type is tuple:

            ## it must not be empty

            if not len(value):

                raise ValueError(
                    "if 'value' is of 'tuple' type, it must" " not be empty"
                )

            ## all of its items must be non-empty strings

            if any(type(item) is not str or not item for item in value):
                raise TypeError(
                    "if 'value' is of 'tuple' type, its items"
                    " must all be non-empty strings"
                )

        ### if type isn't one of the allowed types, raise
        ### TypeError with suitable message

        else:

            raise TypeError("'value' must be of type 'str' or 'tuple'")
Check whether value is of allowed type.
nodezator/widget/pathpreview/base.py