pymensago/keycard.py
def __validate_integer(self, fieldname : str, minVal=-1, maxVal=-1) -> RetVal:
		'''Validates a non-negative integer. Checks range of value if supplied.'''
		if fieldname not in self.fields.keys():
			return RetVal(ErrBadValue, f"field {fieldname} does not exist")
		
		m = re.match(r'^[0-9]+$', self.fields[fieldname])
		if not m:
			return RetVal(ErrBadData, 'bad field value')
		
		intValue = 0
		try:
			intValue = int(m[0])
		except:
			return RetVal(ErrBadData, 'bad field value')
		
		if minVal != -1 and intValue < minVal:
			return RetVal(ErrBadData, f"field {fieldname} less than minimum")

		if maxVal != -1 and intValue > maxVal:
			return RetVal(ErrBadData, f"field {fieldname} greater than maximum")
		
		return RetVal()
Validates a non-negative integer. Checks range of value if supplied.
Validates a non-negative integer. Checks range of value if supplied.
Validates a non - negative integer . Checks range of value if supplied .
def __validate_integer(self, fieldname : str, minVal=-1, maxVal=-1) -> RetVal:
		if fieldname not in self.fields.keys():
			return RetVal(ErrBadValue, f"field {fieldname} does not exist")
		m = re.match(r'^[0-9]+$', self.fields[fieldname])
		if not m:
			return RetVal(ErrBadData, 'bad field value')
		intValue = 0
		try:
			intValue = int(m[0])
		except:
			return RetVal(ErrBadData, 'bad field value')
		if minVal != -1 and intValue < minVal:
			return RetVal(ErrBadData, f"field {fieldname} less than minimum")
		if maxVal != -1 and intValue > maxVal:
			return RetVal(ErrBadData, f"field {fieldname} greater than maximum")
		return RetVal()
def __validate_integer ( self , fieldname : str , minVal = - 1 , maxVal = - 1 ) -> RetVal : if fieldname not in self . fields . keys ( ) : return RetVal ( ErrBadValue , f"field {fieldname} does not exist" ) m = re . match ( r'^[0-9]+$' , self . fields [ fieldname ] ) if not m : return RetVal ( ErrBadData , 'bad field value' ) intValue = 0 try : intValue = int ( m [ 0 ] ) except : return RetVal ( ErrBadData , 'bad field value' ) if minVal != - 1 and intValue < minVal : return RetVal ( ErrBadData , f"field {fieldname} less than minimum" ) if maxVal != - 1 and intValue > maxVal : return RetVal ( ErrBadData , f"field {fieldname} greater than maximum" ) return RetVal ( )
Validates a non-negative integer.
Validates a non - negative integer .
'''Validates a non-negative integer. Checks range of value if supplied.'''
self
fieldname
str
minVal
maxVal