model/identity.py
def is_id_valid(userid: dict) -> bool:
        """Verfies if a dictionary version of an ID is valid or not"""

        required_keys = ["username", "public_key",
                         "nonce", "timestamp", "hash_value"]

        if Counter(userid.keys()) != Counter(required_keys):
            # If, doesn't matter the order, the keys are not all
            # the same as the expected ones, return False

            return False

        expected_types = {
            "username": str,
            "public_key": str,
            "nonce": int,
            "timestamp": str,
            "hash_value": str
        }

        if any([not isinstance(value, expected_types[key]) for key, value in userid.items()]):
            # Returns false if any of the id values have a
            # different type other than the expected

            return False

        id = ID(**userid)

        if id.is_valid() is False:
            return False

        return True
Verfies if a dictionary version of an ID is valid or not
Verfies if a dictionary version of an ID is valid or not
Verfies if a dictionary version of an ID is valid or not
def is_id_valid(userid: dict) -> bool:
        required_keys = ["username", "public_key",
                         "nonce", "timestamp", "hash_value"]
        if Counter(userid.keys()) != Counter(required_keys):
            return False
        expected_types = {
            "username": str,
            "public_key": str,
            "nonce": int,
            "timestamp": str,
            "hash_value": str
        }
        if any([not isinstance(value, expected_types[key]) for key, value in userid.items()]):
            return False
        id = ID(**userid)
        if id.is_valid() is False:
            return False
        return True
def is_id_valid ( userid : dict ) -> bool : required_keys = [ "username" , "public_key" , "nonce" , "timestamp" , "hash_value" ] if Counter ( userid . keys ( ) ) != Counter ( required_keys ) : return False expected_types = { "username" : str , "public_key" : str , "nonce" : int , "timestamp" : str , "hash_value" : str } if any ( [ not isinstance ( value , expected_types [ key ] ) for key , value in userid . items ( ) ] ) : return False id = ID ( ** userid ) if id . is_valid ( ) is False : return False return True
Verfies if a dictionary version of an ID is valid or not
Verfies if a dictionary version of an ID is valid or not
"""Verfies if a dictionary version of an ID is valid or not""" # If, doesn't matter the order, the keys are not all # the same as the expected ones, return False # Returns false if any of the id values have a # different type other than the expected
userid
dict