Exdantic.Error (exdantic v0.0.2)
View SourceStructured error representation for Exdantic validation errors.
Summary
Types
Functions
Formats an error into a human-readable string.
Examples
iex> error = %Exdantic.Error{path: [:user, :email], code: :format, message: "invalid format"}
iex> Exdantic.Error.format(error)
"user.email: invalid format"
iex> error = %Exdantic.Error{path: [], code: :type, message: "expected string"}
iex> Exdantic.Error.format(error)
": expected string"
Creates a new validation error.
Parameters
path
- Path to the field that caused the errorcode
- Error code identifying the type of errormessage
- Human-readable error message
Examples
iex> Exdantic.Error.new([:user, :email], :format, "invalid email format")
%Exdantic.Error{path: [:user, :email], code: :format, message: "invalid email format"}
iex> Exdantic.Error.new(:name, :required, "field is required")
%Exdantic.Error{path: [:name], code: :required, message: "field is required"}