View Source JSV.Key (jsv v0.3.0)

Helpers around the different key formats used in the resolver, builder and validator states to index sub schemas, referenced schemas, anchor or meta schemas.

For instance:

  • We have a {"$ref": "http://some-schema/#$defs/order"} JSON schema.
  • The builder will build the $ref keyword as a key: {:pointer, "http://some-schema/", ["$defs","order"]}.
  • The builder, via the resolver, will fetch http://some-schema/, store it locally and build validators. Those validators will be stored under the same key ({:pointer, "http://some-schema/", ["$defs","order"]}) in the root schema.
  • When the validator will validate the reference, it will fetch that key from the root schema and apply the retrieved validators to the data.

Summary

Functions

Returns an anchor type key.

Returns a dynamic anchor type key.

Returns a pointer type key.

Returns the namespace of the key.

Creates a new key from an external or local reference.

Returns a string representation of the key, in a URL/JSON pointer format, as chardata.

Types

anchor()

@type anchor() :: {:anchor, binary(), binary()}

dynamic_anchor()

@type dynamic_anchor() :: {:dynamic_anchor, binary(), binary()}

ns()

@type ns() :: binary() | :root

pointer()

@type pointer() :: {:pointer, binary(), [binary()]}

t()

@type t() :: ns() | anchor() | dynamic_anchor() | pointer()

Functions

for_anchor(ns, arg)

@spec for_anchor(ns(), term()) :: anchor()

Returns an anchor type key.

for_dynamic_anchor(ns, arg)

@spec for_dynamic_anchor(ns(), term()) :: dynamic_anchor()

Returns a dynamic anchor type key.

for_pointer(ns, arg)

@spec for_pointer(ns(), term()) :: pointer()

Returns a pointer type key.

namespace_of(binary)

@spec namespace_of(t()) :: ns()

Returns the namespace of the key.

of(binary)

@spec of(ns() | JSV.Ref.t()) :: t()

Creates a new key from an external or local reference.

to_iodata(bin)

@spec to_iodata(t()) :: IO.chardata()

Returns a string representation of the key, in a URL/JSON pointer format, as chardata.