Packages
estructura
1.9.0
1.13.0
1.12.0
1.11.0
1.10.2
1.10.1
1.10.0
1.9.0
1.8.3
1.8.2
1.8.1
1.8.0
1.7.2
1.7.1
1.7.0
1.6.1
1.6.0
1.5.0
1.4.2
1.4.1
1.4.0
1.3.3
1.3.2
1.3.1
1.3.0
1.2.12
1.2.11
1.2.10
1.2.9
1.2.8
1.2.7
1.2.6
1.2.5
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.1.1
1.1.0
1.0.0
0.6.0
0.5.5
0.5.4
0.5.3
0.5.2
0.5.1
0.5.0
0.4.2
0.4.1
0.4.0
0.3.2
0.3.1
0.3.0
0.2.0
0.1.0
Extensions for Elixir structures.
Current section
Files
Jump to
Current section
Files
lib/estructura/nested/type.ex
defmodule Estructura.Nested.Type do
@moduledoc """
The type to be used for coercing, validating, and generation
of the implementation’s instances.
"""
@doc "The generator for the type"
@callback generate() :: StreamData.t(any())
@doc "The generator for the type accepting options"
@callback generate(keyword()) :: StreamData.t(any())
@doc "Coerces the value coming from outside"
@callback coerce(term()) :: {:ok, term()} | {:error, any()}
@doc "Validates the value as being correct"
@callback validate(term()) :: {:ok, term()} | {:error, any()}
defmodule Scaffold do
@moduledoc false
@callback type_module_ast(name :: module(), opts :: keyword()) :: Macro.t()
@spec create(module(), module(), keyword()) :: module() | false
def create(scaffold, name, options) do
with true <- is_atom(scaffold),
true <- Code.ensure_loaded?(scaffold),
true <- function_exported?(scaffold, :type_module_ast, 2),
{:module, module, _bytecode, _} <-
scaffold.type_module_ast(name, options),
do: module
end
end
end