# `JSV.Key`
[🔗](https://github.com/lud/jsv/blob/v0.18.3/lib/jsv/key.ex#L1)

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.

# `anchor`

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

# `dynamic_anchor`

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

# `ns`

```elixir
@type ns() :: JSV.Ref.ns()
```

# `pointer`

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

# `t`

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

# `for_anchor`

```elixir
@spec for_anchor(ns(), binary()) :: anchor()
```

Returns an anchor type key.

# `for_dynamic_anchor`

```elixir
@spec for_dynamic_anchor(ns(), binary()) :: dynamic_anchor()
```

Returns a dynamic anchor type key.

# `for_pointer`

```elixir
@spec for_pointer(ns(), [binary()]) :: pointer()
```

Returns a pointer type key.

# `namespace_of`

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

Returns the namespace of the key.

# `of`

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

Creates a new key from an external or local reference.

# `to_iodata`

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

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
