Skip to main content

Module nsid_syntax

Module nsid_syntax 

Source
Expand description

Namespace identifier syntax, as atproto specifies it.

This is the generic validator, not a check against crate::nsid::ALL. The two answer different questions: this one says whether a string could name a lexicon anywhere in atproto, and ALL says whether this deployment defines it. A collection arriving over the wire needs the second; a lexicon document’s own id, or the collection segment of an at:// URI pointing at somebody else’s repository, needs the first.

§The authority is reversed, and that is the whole trick

An NSID is a domain authority written backwards with a name segment on the end, so com.example.fooBar belongs to example.com. Reversal is why the first segment is the one that may not start with a digit: it is the top-level domain. org.4chan.lex.getThing is fine and 1.0.0.127.record is not, for exactly the reason 4chan.org is a domain and 127.0.0.1 is not.

Enums§

NsidError
Why a string is not a syntactically valid NSID.

Constants§

MAX_AUTHORITY_LENGTH
Longest the reversed domain authority may be, matching DNS.
MAX_NSID_LENGTH
Longest an NSID may be: a 253-character domain authority, a dot, and a 63-character name.
MAX_SEGMENT_LENGTH
Longest any one segment may be, matching a DNS label.

Functions§

validate
Checks a string against the NSID syntax rules.