Validixir.Error (validixir v1.2.2)
Module containing data definition and functionality concerning an Error. An Error is a struct representing a concrete error in validation.
An Error consists of the following:
- A candidate, representing the value that was validated
- A message, describing the cause of the Error
- A context in which the Error occured, e.g. a module or step
Link to this section Summary
Functions
Augments the context of an error.
Augments the message of an error.
Smart constructor of an error.
Overrides the context of an error.
Overrides the message of an error.
Link to this section Types
Link to this section Functions
Link to this function
augment_context(error, additional_context)
Augments the context of an error.
examples
Examples
iex> Validixir.Error.augment_context(Validixir.Error.make(12, :message, Context), NewContext)
%Validixir.Error{candidate: 12, message: :message, context: [NewContext, Context]}
Link to this function
augment_message(error, additional_message)
Augments the message of an error.
examples
Examples
iex> Validixir.Error.augment_message(Validixir.Error.make(12, :message, Context), :new_message)
%Validixir.Error{candidate: 12, message: [:new_message, :message], context: Context}
Link to this function
make(candidate, message, context)
Smart constructor of an error.
Link to this function
with_context(error, context)
Overrides the context of an error.
examples
Examples
iex> Validixir.Error.with_context(Validixir.Error.make(12, :message, Context), NewContext)
%Validixir.Error{candidate: 12, message: :message, context: NewContext}
Link to this function
with_message(error, message)
Overrides the message of an error.
examples
Examples
iex> Validixir.Error.with_message(Validixir.Error.make(12, :message, Context), :new_message)
%Validixir.Error{candidate: 12, message: :new_message, context: Context}