pymensago/keycard.py
def __validate_user_data(self) -> RetVal:
		'''Checks the validity of all data fields'''
		if self.type != 'User':
			return RetVal(ErrBadData, 'invalid entry type %s' % self.type)
		
		outStatus = self.__validate_common_data()
		if outStatus.error():
			return outStatus

		# Required field: Workspace ID
		m = re.match(r'^[\da-fA-F]{8}-?[\da-fA-F]{4}-?[\da-fA-F]{4}-?[\da-fA-F]{4}'
			r'-?[\da-fA-F]{12}$', self.fields['Workspace-ID'])
		if not m:
			return RetVal(ErrBadData, 'bad workspace ID')

		# Required field: Domain
		# Although mostly freeform, the Name field has a couple requirements:
		m = re.match(r'([a-zA-Z0-9]+\.)+[a-zA-Z0-9]+', self.fields['Domain'])
		if not m or len(self.fields['Domain']) >= 64:
			return RetVal(ErrBadData, 'bad domain value')

		# Required fields: Contact Request Verification Key, Contact Request Encryption Key,
		#	Encryption-Key, Verification-Key
		for keyfield in ['Contact-Request-Verification-Key',
						 'Contact-Request-Encryption-Key',
						 'Encryption-Key',
						 'Verification-Key']:
			if not is_cryptostring(self.fields[keyfield]):
				return RetVal(ErrBadData, f"bad key field {keyfield}")

		# Optional field: User ID
		if 'User-ID' in self.fields.keys():
			if re.findall(r'[\\\/\s"]', self.fields['User-ID']) or \
				len(self.fields['User-ID']) >= 64:
				return RetVal(ErrBadData, 'bad user id value')
			
		return RetVal()
Checks the validity of all data fields
Checks the validity of all data fields
Checks the validity of all data fields
def __validate_user_data(self) -> RetVal:
		if self.type != 'User':
			return RetVal(ErrBadData, 'invalid entry type %s' % self.type)
		outStatus = self.__validate_common_data()
		if outStatus.error():
			return outStatus
		m = re.match(r'^[\da-fA-F]{8}-?[\da-fA-F]{4}-?[\da-fA-F]{4}-?[\da-fA-F]{4}'
			r'-?[\da-fA-F]{12}$', self.fields['Workspace-ID'])
		if not m:
			return RetVal(ErrBadData, 'bad workspace ID')
		m = re.match(r'([a-zA-Z0-9]+\.)+[a-zA-Z0-9]+', self.fields['Domain'])
		if not m or len(self.fields['Domain']) >= 64:
			return RetVal(ErrBadData, 'bad domain value')
		for keyfield in ['Contact-Request-Verification-Key',
						 'Contact-Request-Encryption-Key',
						 'Encryption-Key',
						 'Verification-Key']:
			if not is_cryptostring(self.fields[keyfield]):
				return RetVal(ErrBadData, f"bad key field {keyfield}")
		if 'User-ID' in self.fields.keys():
			if re.findall(r'[\\\/\s"]', self.fields['User-ID']) or \
				len(self.fields['User-ID']) >= 64:
				return RetVal(ErrBadData, 'bad user id value')
		return RetVal()
def __validate_user_data ( self ) -> RetVal : if self . type != 'User' : return RetVal ( ErrBadData , 'invalid entry type %s' % self . type ) outStatus = self . __validate_common_data ( ) if outStatus . error ( ) : return outStatus m = re . match ( r'^[\da-fA-F]{8}-?[\da-fA-F]{4}-?[\da-fA-F]{4}-?[\da-fA-F]{4}' r'-?[\da-fA-F]{12}$' , self . fields [ 'Workspace-ID' ] ) if not m : return RetVal ( ErrBadData , 'bad workspace ID' ) m = re . match ( r'([a-zA-Z0-9]+\.)+[a-zA-Z0-9]+' , self . fields [ 'Domain' ] ) if not m or len ( self . fields [ 'Domain' ] ) >= 64 : return RetVal ( ErrBadData , 'bad domain value' ) for keyfield in [ 'Contact-Request-Verification-Key' , 'Contact-Request-Encryption-Key' , 'Encryption-Key' , 'Verification-Key' ] : if not is_cryptostring ( self . fields [ keyfield ] ) : return RetVal ( ErrBadData , f"bad key field {keyfield}" ) if 'User-ID' in self . fields . keys ( ) : if re . findall ( r'[\\\/\s"]' , self . fields [ 'User-ID' ] ) or len ( self . fields [ 'User-ID' ] ) >= 64 : return RetVal ( ErrBadData , 'bad user id value' ) return RetVal ( )
Checks the validity of all data fields
Checks the validity of all data fields
'''Checks the validity of all data fields''' # Required field: Workspace ID # Required field: Domain # Although mostly freeform, the Name field has a couple requirements: # Required fields: Contact Request Verification Key, Contact Request Encryption Key, #	Encryption-Key, Verification-Key # Optional field: User ID
self