Lower-level, spec-aligned AT Protocol (ATProto) building blocks.
This namespace is intended to stay close to the AT Protocol specifications
(see atproto.com): one submodule per spec domain
(NSID, RecordKey, AtUri, TID, CBOR, CID, CAR, MST,
DataModel, …), with Identity and Repo grouping their own submodules.
The namespace root is the protocol's front door: it composes the submodules
into protocol-level entry points without implementing anything itself.
validate/2 dispatches to the spec-aligned validators so callers don't need
to know which submodule owns which grammar:
:ok = Exosphere.ATProto.validate(:nsid, "app.bsky.feed.post")
:ok = Exosphere.ATProto.validate(:record, %{"$type" => "com.example.post"})For higher-level, end-user APIs (XRPC clients, firehose, etc.), prefer the
Exosphere.* facade modules, which compose these building blocks.
Summary
Functions
Validate a value against an AT Protocol grammar or data model.
Types
Functions
Validate a value against an AT Protocol grammar or data model.
Dispatches to the submodule validator that owns each kind, normalizing
their boolean/{:error, _} returns into :ok | {:error, reason}:
| Kind | Validates | Owner |
|---|---|---|
:nsid | NSID syntax | NSID |
:rkey | record key syntax | RecordKey |
:at_uri | at:// URI syntax (errors carry the parse reason, e.g. :invalid_authority or :invalid_rkey) | AtUri |
:tid | TID syntax | TID |
:did | DID syntax | Identity.DID |
:handle | handle syntax | Identity.Handle |
:cid | CID string (blessed atproto format) | CID |
:mst_key | MST record path (nsid/rkey) | MST |
:record | atproto data-model record | DataModel |
Examples
iex> Exosphere.ATProto.validate(:nsid, "app.bsky.feed.post")
:ok
iex> Exosphere.ATProto.validate(:tid, "not-a-tid")
{:error, :invalid_tid}
iex> Exosphere.ATProto.validate(:at_uri, "https://example.com")
{:error, :invalid_scheme}
iex> Exosphere.ATProto.validate(:record, %{"a" => 1.5})
{:error, {"a", :non_integral_float}}
iex> Exosphere.ATProto.validate("nsid", "app.bsky.feed.post")
{:error, {:unknown_validation_kind, "nsid"}}