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

		# Required field: Admin address
		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}/([a-zA-Z0-9]+\.)+[a-zA-Z0-9]+$', self.fields['Contact-Admin'])
		if not m:
			return RetVal(ErrBadData, 'bad admin contact address')

		# Required fields: Primary Verification Key, Encryption Key
		# We can't verify the actual key data, but we can at least ensure that it's formatted
		# correctly and we can b85decode the key itself
		for keyfield in ['Primary-Verification-Key', 'Encryption-Key']:
			if not is_cryptostring(self.fields[keyfield]):
				return RetVal(ErrBadData, f"bad key field {keyfield}")
		
		# Optional fields: Support and Abuse addresses
		for contactfield in ['Contact-Support','Contact-Abuse']:
			if contactfield in self.fields.keys():
				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}/([a-zA-Z0-9]+\.)+[a-zA-Z0-9]+$',
					self.fields[contactfield])
				if not m:
					return RetVal(ErrBadData, f"bad contact address {contactfield}")
		
		# Optional field: Language
		if 'Language' in self.fields.keys():
			m = re.match(r'^[a-zA-Z]{2,3}(,[a-zA-Z]{2,3})*?$', self.fields['Language'])
			if not m:
				return RetVal(ErrBadData, 'bad language list')

		# Optional field: Secondary Verification Key
		if 'Secondary-Verification-Key' in self.fields.keys():
			if not is_cryptostring(self.fields['Secondary-Verification-Key']):
				return RetVal(ErrBadData, 'bad secondary verification key')
		
		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_org_data(self) -> RetVal:
		if self.type != 'Organization':
			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}/([a-zA-Z0-9]+\.)+[a-zA-Z0-9]+$', self.fields['Contact-Admin'])
		if not m:
			return RetVal(ErrBadData, 'bad admin contact address')
		for keyfield in ['Primary-Verification-Key', 'Encryption-Key']:
			if not is_cryptostring(self.fields[keyfield]):
				return RetVal(ErrBadData, f"bad key field {keyfield}")
		for contactfield in ['Contact-Support','Contact-Abuse']:
			if contactfield in self.fields.keys():
				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}/([a-zA-Z0-9]+\.)+[a-zA-Z0-9]+$',
					self.fields[contactfield])
				if not m:
					return RetVal(ErrBadData, f"bad contact address {contactfield}")
		if 'Language' in self.fields.keys():
			m = re.match(r'^[a-zA-Z]{2,3}(,[a-zA-Z]{2,3})*?$', self.fields['Language'])
			if not m:
				return RetVal(ErrBadData, 'bad language list')
		if 'Secondary-Verification-Key' in self.fields.keys():
			if not is_cryptostring(self.fields['Secondary-Verification-Key']):
				return RetVal(ErrBadData, 'bad secondary verification key')
		return RetVal()
def __validate_org_data ( self ) -> RetVal : if self . type != 'Organization' : 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}/([a-zA-Z0-9]+\.)+[a-zA-Z0-9]+$' , self . fields [ 'Contact-Admin' ] ) if not m : return RetVal ( ErrBadData , 'bad admin contact address' ) for keyfield in [ 'Primary-Verification-Key' , 'Encryption-Key' ] : if not is_cryptostring ( self . fields [ keyfield ] ) : return RetVal ( ErrBadData , f"bad key field {keyfield}" ) for contactfield in [ 'Contact-Support' , 'Contact-Abuse' ] : if contactfield in self . fields . keys ( ) : 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}/([a-zA-Z0-9]+\.)+[a-zA-Z0-9]+$' , self . fields [ contactfield ] ) if not m : return RetVal ( ErrBadData , f"bad contact address {contactfield}" ) if 'Language' in self . fields . keys ( ) : m = re . match ( r'^[a-zA-Z]{2,3}(,[a-zA-Z]{2,3})*?$' , self . fields [ 'Language' ] ) if not m : return RetVal ( ErrBadData , 'bad language list' ) if 'Secondary-Verification-Key' in self . fields . keys ( ) : if not is_cryptostring ( self . fields [ 'Secondary-Verification-Key' ] ) : return RetVal ( ErrBadData , 'bad secondary verification key' ) 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: Admin address # Required fields: Primary Verification Key, Encryption Key # We can't verify the actual key data, but we can at least ensure that it's formatted # correctly and we can b85decode the key itself # Optional fields: Support and Abuse addresses # Optional field: Language # Optional field: Secondary Verification Key
self