Skip to main content

validate_collection

Function validate_collection 

Source
pub fn validate_collection(collection: &str) -> Result<(), ShapeError>
Expand description

The first of validate_with’s rules, on its own.

Split out for the operations that name a collection and carry no record — a deleteRecord, or the delete half of an applyWrites batch.

It asks only whether the string could name a lexicon. It deliberately does not ask whether this deployment defines one: a personal data server holds the account’s repository, and the lexicons an account may write are the world’s rather than this project’s.

use didbot_schema::validate_collection;
assert!(validate_collection("com.example.thing").is_ok());
// A lexicon this project did not author, and does not hold.
assert!(validate_collection("app.bsky.feed.post").is_ok());
// Not an NSID at all, so it could never address anything.
assert!(validate_collection("post").is_err());