import re


def did_validate(did: str) -> bool:
    """

    Validate a did string.

    :param str did: DID string to validate, this can be an agent did or an asset_did
    :return: True if the did is valid
    :raise: TypeError if did is not a string
    :raise: ValueError if the DID is invalid

    """
    if not isinstance(did, str):
        raise TypeError('Expecting DID of string type, got %s of %s type' % (did, type(did)))

    if not re.match('^did:', did, re.IGNORECASE):
        raise ValueError(f'DID {did} must start with the text "did"')

    if not re.match('^did:([a-z0-9]+):', did, re.IGNORECASE):
        raise ValueError(f'DID {did} "id" must have only a-z 0-9 characters')

    if not re.match('^did:[a-z0-9]+:[a-f0-9]{64}.*', did, re.IGNORECASE):
        raise ValueError(f'DID {did} path should only have hex characters')
    return True