Skip to main content

validate_record_key

Function validate_record_key 

Source
pub fn validate_record_key(rkey: &str) -> Result<(), RecordKeyError>
Expand description

Checks a string against the record key rules.

This is the generic rule, which is far looser than what this server mints: every key didbot-pds’s record store produces is a TID, and a TID is a much narrower thing (see crate::tid). Both matter. Keys arriving from elsewhere — in an at:// URI naming somebody else’s record — follow only this rule, and treating them as TIDs would reject self, which is the key every singleton record in atproto uses.

use didbot_schema::validate_record_key;
assert!(validate_record_key("self").is_ok());
assert!(validate_record_key("3jzfcijpj2z2a").is_ok());
assert!(validate_record_key("..").is_err());
assert!(validate_record_key("alpha/beta").is_err());