code: def _validate_enum(self, item: Any, enum: Any) -> Any:
          
          if item is None:
              result = get_random_item(enum, self.random)
          elif item and isinstance(item, enum):
              result = item
          else:
              raise NonEnumerableError(enum)
  
          return result.value
docs: Validate enum parameter of method in subclasses of BaseProvider.
  
          :param item: Item of enum object.
          :param enum: Enum object.
          :return: Value of item.
          :raises NonEnumerableError: if ``item`` not in ``enum``.