Zoi.TypeSpec protocol (Zoi v0.17.0)

View Source

Protocol for generating Elixir type specifications from Zoi schemas.

Each type can implement this protocol to define how it should be represented as an Elixir typespec. This is used by Zoi.type_spec/1 to generate type specifications that can be used with @type attributes.

Example

defmodule MyCustomType do
  use Zoi.Type.Def

  defimpl Zoi.TypeSpec do
    def spec(_schema, _opts) do
      quote(do: my_custom_type())
    end
  end
end

Summary

Types

t()

All the types that implement this protocol.

Functions

Returns a quoted Elixir type specification for the given schema.

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

spec(schema, opts)

@spec spec(Zoi.schema(), Zoi.options()) :: Macro.t()

Returns a quoted Elixir type specification for the given schema.