is_valid_did_method_plc

Function is_valid_did_method_plc 

Source
pub fn is_valid_did_method_plc(did: &str) -> bool
Expand description

Validates if a string is a properly formatted PLC DID.

A valid PLC DID must:

  • Start with the prefix did:plc:
  • Be followed by exactly 24 characters of base32 encoding (lowercase letters a-z and digits 2-7)

§Arguments

  • did - The DID string to validate

§Returns

true if the DID is a valid PLC DID, false otherwise

§Examples

use atproto_identity::validation::is_valid_did_method_plc;

// Valid PLC DIDs
assert!(is_valid_did_method_plc("did:plc:z3f2222fa222f5c33c2f27ez"));
assert!(is_valid_did_method_plc("did:plc:abcdefghijklmnopqrstuvwx"));

// Invalid PLC DIDs
assert!(!is_valid_did_method_plc("did:web:example.com"));
assert!(!is_valid_did_method_plc("did:plc:invalid0length"));
assert!(!is_valid_did_method_plc("did:plc:UPPERCASE_NOT_ALLOWED"));