View Source Elixact.Error (elixact v0.1.1)

Structured error representation for Elixact validation errors.

Summary

Functions

Formats an error into a human-readable string.

Creates a new validation error.

Types

@type t() :: %Elixact.Error{
  code: atom(),
  message: String.t(),
  path: [atom() | String.t()]
}

Functions

Formats an error into a human-readable string.

Example

iex> Error.format(%Error{path: [:user, :email], code: :format, message: "invalid format"})
"user.email: invalid format"
Link to this function

new(path, code, message)

View Source

Creates a new validation error.

Parameters

  • path - Path to the field that caused the error
  • code - Error code identifying the type of error
  • message - Human-readable error message

Example

iex> Error.new([:user, :email], :format, "invalid email format")
%Error{path: [:user, :email], code: :format, message: "invalid email format"}