docs: def validate_packet(self, data):
          """Validate a packet against this packet handler and determine if it
          meets the requirements. This is done by checking the following
          conditions are true.
  
          - The length of the packet is equal to the first byte.
          - The second byte is in the set of defined PACKET_TYPES for this class.
          - The third byte is in the set of this class defined PACKET_SUBTYPES.
  
          If one or more of these conditions isn't met then we have a packet that
          isn't valid or at least isn't understood by this handler.
  
          :param data: bytearray to be verified
          :type data: bytearray
  
  
          :raises: :py:class:`rfxcom.exceptions.InvalidPacketLength`: If the
              number of bytes in the packet doesn't match the expected length.
  
          :raises: :py:class:`rfxcom.exceptions.UnknownPacketType`: If the packet
              type is unknown to this packet handler
  
          :raises: :py:class:`rfxcom.exceptions.UnknownPacketSubtype`: If the
              packet sub type is unknown to this packet handler
  
          :return: true is returned if validation passes.
          :rtype: boolean
  
          """
  
          # Validate length.
          # The first byte in the packet should be equal to the number of
          # remaining bytes (i.e. length excluding the first byte).
          expected_length = data[0] + 1
  
          if len(data) != expected_length:
              raise InvalidPacketLength(
                  "Expected packet length to be %s bytes but it was %s bytes"
                  % (expected_length, len(data))
              )
  
          # Validate minimal length.
          # The packet contains at least the RFX header:
          #  packet_length (1 byte) + packet_type (1 byte)
          #  + packet_subtype (1 byte) + sequence_number (1 byte)
          if expected_length < 4:
              raise MalformedPacket(
                      "Expected packet length to be larger than 4 bytes but \
                      it was %s bytes"
                      % (len(data))
              )
  
          # Validate Packet Type.
          # This specifies the family of devices.
          # Check it is one of the supported packet types
          packet_type = data[1]
  
          if self.PACKET_TYPES and packet_type not in self.PACKET_TYPES:
              types = ",".join("0x{:02x}".format(pt) for pt in self.PACKET_TYPES)
              raise UnknownPacketType(
                  "Expected packet type to be one of [%s] but recieved %s"
                  % (types, packet_type)
              )
  
          # Validate Packet Subtype.
          # This specifies the sub-family of devices.
          # Check it is one of the supported packet subtypes for current type
          sub_type = data[2]
  
          if self.PACKET_SUBTYPES and sub_type not in self.PACKET_SUBTYPES:
              types = \
                  ",".join("0x{:02x}".format(pt) for pt in self.PACKET_SUBTYPES)
              raise UnknownPacketSubtype(
                  "Expected packet type to be one of [%s] but recieved %s"
                  % (types, sub_type))
  
          return True