Zot.Type protocol (zot v0.12.0)

View Source

Protocol for defining Zot types.

Summary

Types

Raw input value.

Parsed and validated value.

The portion of an invalid input that was successfully parsed and validated.

t()

All the types that implement this protocol.

Functions

Converts the type into a JSON Schema.

Parses a value according to the given type.

Types

input()

@type input() :: term()

Raw input value.

output()

@type output() :: term()

Parsed and validated value.

partial()

@type partial() :: term()

The portion of an invalid input that was successfully parsed and validated.

t()

@type t() :: term()

All the types that implement this protocol.

Functions

json_schema(type)

@spec json_schema(t()) :: map()

Converts the type into a JSON Schema.

parse(type, value, opts \\ [])

@spec parse(t(), input(), [option]) ::
  {:ok, output()}
  | {:error, [Zot.Issue.t(), ...]}
  | {:error, [Zot.Issue.t(), ...], partial()}
when option: {:coerce, boolean() | :unsafe} | {atom(), term()}

Parses a value according to the given type.