Skip to main content

validate_label

Function validate_label 

Source
pub fn validate_label(label: &str) -> Result<(), DidError>
Expand description

Checks one DNS label. Uppercase is rejected rather than normalized: a DID is compared byte for byte across the network, so two spellings of one identity would be two identities.

This is the authority on what an agent id may be: AccountDid::mint and validate_hostname (this crate’s did:web host check) both call it rather than a copy, and anything upstream that generates a label — a namer, or any derivation — should too. Two validators that disagree about which labels are legal is how an illegal one reaches DNS: one accepts what the other would have refused. This function has no notion of a maximum label length; that is a DNS-label rule with no did:web-specific meaning, and a caller that cares (didbot-name, publishing under a zone) enforces its own bound on top of this.