Validixir.Success (validixir v1.2.2)
Module containing data definition and functionality concerning a Success. A Success is a :ok tuple representing a successful validation of a candidate.
Link to this section Summary
Functions
Smart constructor of a success.
Applies a function to the candidate of a success.
Returns true if a value is a success.
Link to this section Types
Link to this type
some_inner_t()
@type some_inner_t() :: any()
Link to this type
t(inner_t)
@type t(inner_t) :: {:ok, inner_t}
Link to this section Functions
Link to this function
make(candidate)
@spec make(some_inner_t()) :: t(some_inner_t())
Smart constructor of a success.
Link to this function
map(arg, f)
@spec map(t(some_inner_t()), (some_inner_t() -> any())) :: t(any())
Applies a function to the candidate of a success.
examples
Examples
iex> Validixir.Success.map(Validixir.Success.make(0), fn a -> a + 1 end)
{:ok, 1}
Link to this function
success?(arg1)
Returns true if a value is a success.
examples
Examples
iex> f = Validixir.Failure.make([])
iex> Validixir.Success.success?(f)
false
iex> s = Validixir.Success.make(1)
iex> Validixir.Success.success?(s)
true