xema v0.4.0 Xema.Ref View Source

This module contains a struct and function to represent and handle references.

Link to this section Summary

Functions

Returns the pointer of the given reference

Creates a new reference from the given pointer

Returns the binary representation of a reference

Validates the given value with the referenced schema

Link to this section Types

Link to this type t() View Source
t() :: %Xema.Ref{path: String.t() | nil, pointer: String.t(), remote: boolean(), url: String.t() | nil}

Link to this section Functions

Link to this function get_pointer(ref) View Source
get_pointer(Xema.Ref.t()) :: String.t()

Returns the pointer of the given reference.

Creates a new reference from the given pointer.

Examples

iex> Xema.Ref.new("http://foo.com/bar/baz.exon#/definitions/abc")
%Xema.Ref{
  path: "/bar/baz.exon",
  pointer: "/definitions/abc",
  remote: true,
  url: "http://foo.com:80"
}

Returns the binary representation of a reference.

Examples

iex> "http://foo.com/bar/baz.exon#/definitions/abc"
...> |> Xema.Ref.new()
...> |> Xema.Ref.to_string()
"{:ref, \"http://foo.com/bar/baz.exon#/definitions/abc\"}"
Link to this function validate(ref, value, opts) View Source
validate(Xema.Ref.t(), any(), keyword()) :: :ok | {:error, map()}

Validates the given value with the referenced schema.