Check that the payload is long enough (at least 2 bytes).
482602
def pre_dissect(self, s):
        
        length = len(s)
        if length < _BGP_CAPABILITY_MIN_SIZE:
            err = " ({}".format(length) + " is < _BGP_CAPABILITY_MIN_SIZE "
            err += "({})).".format(_BGP_CAPABILITY_MIN_SIZE)
            raise _BGPInvalidDataException(err)
        return s
260502
def _check_title_length(title, api):
    '''  '''
    if len(title) > api.MAX_LIST_TITLE_LENGTH:
        raise ValueError("Title cannot be longer than {} characters".format(api.MAX_TASK_TITLE_LENGTH))
628498
function validateLength(attr, conf, err) {
    if (nullCheck.call(this, attr, conf, err)) return;

    var len = this[attr].length;
    if (conf.min && len < conf.min) {
        err('min');
    }
    if (conf.max && len > conf.max) {
        err('max');
    }
    if (conf.is && len !== conf.is) {
        err('is');
    }
}
303328
def wr_long(f, x):
    """"""
    if PYTHON3:
        f.write(bytes([x        & 0xff]))
        f.write(bytes([(x >> 8)  & 0xff]))
        f.write(bytes([(x >> 16) & 0xff]))
        f.write(bytes([(x >> 24) & 0xff]))
    else:
        f.write(chr( x        & 0xff))
        f.write(chr((x >> 8)  & 0xff))
        f.write(chr((x >> 16) & 0xff))
        f.write(chr((x >> 24) & 0xff))
422877
function checkLength(str) {
        var ctm = ctx.measureText(str);
        return ctm.width <= tm.width;
      }
517250
def set_length_and_maybe_checksums(self, record, payload_offset=None):
        ''''''
        if self._params.digests:
            record.compute_checksum(payload_offset)
        else:
            record.set_content_length()
262757
def validate(self):
		
		if self.implemented_protocol_version != self.protocol_version:
			raise OmapiError("protocol mismatch")
		if self.implemented_header_size != self.header_size:
			raise OmapiError("header size mismatch")
1138484
protected long validateAndAdjustLenght(long length, long position, long dataLength) throws IOException
   {
      if (position < 0)
      {
         throw new IOException("Position must be higher or equals 0. But given " + position);
      }

      if (length < 0)
      {
         throw new IOException("Length must be higher or equals 0. But given " + length);
      }

      if (position >= dataLength && position > 0)
      {
         throw new IOException("Position " + position + " out of value size " + dataLength);
      }

      if (position + length >= dataLength)
      {
         return dataLength - position;
      }

      return length;
   }
1184235
def _update_length(self):
        
        payload = type(self).oxm_value.pack(self.oxm_value)
        self.oxm_length = len(payload)
324005
def validate_bytes(data, length=4):
        '''
        
        '''
        if (not isinstance(data, ByteData)
                and not isinstance(data, bytes)
                and not isinstance(data, bytearray)):
            raise ValueError('Expected byte-like object. '
                             'Got: {}'.format(type(data)))

        if length is None:
            return

        if len(data) != length:
            raise ValueError('Expected byte-like object with length {}. '
                             'Got {} with length {}.'
                             .format(length, type(data), len(data)))
650900
def long2str(l):
    """"""
    if type(l) not in (types.IntType, types.LongType):
        raise ValueError('the input must be an integer')

    if l < 0:
        raise ValueError('the input must be greater than 0')
    s = ''
    while l:
        s = s + chr(l & 255)
        l >>= 8

    return s
606834
private boolean matchLong(final ByteBuffer bbuf, final ByteOrder bo, final boolean needMask, final long lMask) throws IOException {
		bbuf.order(bo);
		long got;
		final String testContent = getContent();
		if (testContent.startsWith("0x")) {
			got = Long.parseLong(testContent.substring(2), 16);
		} else if (testContent.startsWith("&")) {
			got = Long.parseLong(testContent.substring(3), 16);
		} else {
			got = Long.parseLong(testContent);
		}

		long found = bbuf.getInt();

		if (needMask) {
			found = (short) (found & lMask);
		}

		if (got != found) {
			return false;
		}

		return true;
	}
714312
def _encode_long(name, value, dummy0, dummy1):
    """"""
    try:
        return b"\x12" + name + _PACK_LONG(value)
    except struct.error:
        raise OverflowError("BSON can only handle up to 8-byte ints")
841180
public static void hasLength(String input, int length, String message) {

    notNull(input, message);
    if (input.trim().length() != length) {
      throw new IllegalArgumentException(message);
    }
  }
1189510
private void check(int length) {
    if (size + length >= buf.length) {
      buf = Arrays.copyOf(buf, buf.length + length + 16);
    }
  }
1257931
def _check_content(self, content_str):
        """"""
        if self.do_content_check:
            space_ratio = float(content_str.count(' '))/len(content_str)
            if space_ratio > self.max_space_ratio:
                return "space-ratio: %f > %f" % (space_ratio,
                                                 self.max_space_ratio)
            if len(content_str) > self.input_character_limit:
                return "too long: %d > %d" % (len(content_str),
                                              self.input_character_limit)
        return None
344689
def Size(self):
        
        return s.uint32 + 12 + s.uint32 + s.uint32 + len(self.Payload)