code: def pack(self, value=None):
          
          if value is None:
              if not self.is_valid():
                  error_msg = "Error on validation prior to pack() on class "
                  error_msg += "{}.".format(type(self).__name__)
                  raise ValidationError(error_msg)
              else:
                  message = b''
                  # pylint: disable=no-member
                  for attr_info in self._get_named_attributes():
                      name, instance_value, class_value = attr_info
                      try:
                          message += class_value.pack(instance_value)
                      except PackException as pack_exception:
                          cls = type(self).__name__
                          msg = f'{cls}.{name} - {pack_exception}'
                          raise PackException(msg)
                  return message
          elif isinstance(value, type(self)):
              return value.pack()
          else:
              msg = "{} is not an instance of {}".format(value,
                                                         type(self).__name__)
              raise PackException(msg)
docs: Pack the struct in a binary representation.
  
          Iterate over the class attributes, according to the
          order of definition, and then convert each attribute to its byte
          representation using its own ``pack`` method.
  
          Returns:
              bytes: Binary representation of the struct object.
  
          Raises:
              :exc:`~.exceptions.ValidationError`: If validation fails.