Skip to main content

Function: toNSID()

toNSID(nsid): null | NSID

Defined in: src/types/atproto-validators.ts:174

Validates and brands an NSID string.

Parameters​

nsid​

string

Potential NSID string

Returns​

null | NSID

Branded NSID if valid, null otherwise

Remarks​

NSID format: authority.name.subname (reverse domain notation)

Validation rules:

  • Lowercase alphabetic segments separated by periods
  • At least two segments (e.g., "pub.chive")
  • Each segment must be non-empty
  • No leading or trailing periods

Common Chive NSIDs:

  • pub.chive.eprint.submission
  • pub.chive.review.comment
  • pub.chive.graph.nodeProposal

Example​

const valid = toNSID('pub.chive.eprint.submission');
console.log(valid); // 'pub.chive.eprint.submission'

const invalid = toNSID('InvalidNSID');
console.log(invalid); // null