View Source Xema.Ref (xema v0.17.5)

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

Summary

Types

t()

A reference contains a pointer and an optional uri.

Functions

Returns the schema and the root for the given ref and xema.

Returns the reference key for a Ref or an URI.

Creates a new reference from the given pointer.

Creates a new reference from the given pointer and uri.

Validates the given value with the referenced schema.

Types

t()

@type t() :: %Xema.Ref{pointer: String.t(), uri: URI.t() | nil}

A reference contains a pointer and an optional uri.

Functions

fetch!(ref, master, root)

@spec fetch!(t(), struct(), struct() | nil) :: {struct() | atom(), struct()}

Returns the schema and the root for the given ref and xema.

fragment(ref)

key(uri)

@spec key(ref :: t() | URI.t()) :: String.t()

Returns the reference key for a Ref or an URI.

new(pointer)

@spec new(String.t()) :: t()

Creates a new reference from the given pointer.

new(pointer, uri)

@spec new(String.t(), URI.t() | nil) :: t()

Creates a new reference from the given pointer and uri.

validate(ref, value, opts)

@spec validate(t(), any(), keyword()) :: :ok | {:error, map()}

Validates the given value with the referenced schema.