exchema v0.2.0 Exchema.Type behaviour

This is the contract of a type module.

To implement your own type you should just implement the ___type__/1 callback which receives a tuple with your type arguments. If you have a concrete type, then it should match on receiving an empty tuple {}.

Link to this section Summary

Link to this section Types

Link to this type error()
error() :: {:error, any()}
Link to this type predicate()
predicate() :: {module(), atom()} | atom()
Link to this type predicate_failure()
predicate_failure() :: false | error() | [error(), ...]
Link to this type predicate_fun()
predicate_fun() :: (any(), any() -> predicate_result())
Link to this type predicate_result()
predicate_result() :: predicate_failure() | predicate_success()
Link to this type predicate_spec()
predicate_spec() :: {predicate(), any()}
Link to this type predicate_success()
predicate_success() :: :ok | true | []
Link to this type refined_type()
refined_type() :: {:ref, t(), [predicate_spec()]}
Link to this type t()
t() :: module()
Link to this type type_params()
type_params() :: tuple()
Link to this type type_reference()
type_reference() :: t() | {t(), type_params()}
Link to this type type_spec()
type_spec() :: type_reference() | refined_type()

Link to this section Functions

Link to this function resolve_type(type)
resolve_type(Type.type_reference()) :: Type.t() | Type.refined_type()

Link to this section Callbacks

Link to this callback __type__(type_params)
__type__(type_params()) :: type_spec()