//! Example of validating did:plc identifiers use atproto_plc::Did; fn main() { println!("DID Validation Examples\n"); println!("{}", "=".repeat(60)); let test_dids = vec![ ("did:plc:ewvi7nxzyoun6zhxrhs64oiz", true, "Valid DID"), ("did:plc:z72i7hdynmk6r22z27h6tvur", true, "Valid DID"), ("did:plc:abc123", false, "Too short"), ( "did:plc:0123456789012345678901234", false, "Contains invalid characters (0,1,8,9)", ), ( "DID:PLC:EWVI7NXZYOUN6ZHXRHS64OIZ", false, "Uppercase not allowed", ), ("did:web:example.com", false, "Wrong DID method"), ( "did:plc:ewvi7nxzyoun6zhxrhs64oizextrachars", false, "Too long", ), ]; for (did_str, should_be_valid, description) in test_dids { print!("\nTesting: {}\n ", did_str); print!("Description: {}\n ", description); match Did::parse(did_str) { Ok(did) => { if should_be_valid { println!("✅ Valid"); println!(" Identifier: {}", did.identifier()); println!(" Full DID: {}", did.as_str()); } else { println!("❌ ERROR: Expected invalid, but was accepted!"); } } Err(e) => { if !should_be_valid { println!("✅ Correctly rejected"); println!(" Reason: {}", e); } else { println!("❌ ERROR: Expected valid, but was rejected!"); println!(" Error: {}", e); } } } } println!("\n{}", "=".repeat(60)); println!("\nValidation complete!"); }