A fault in a document, {path, reason}, and the one formatter that words it (spec/01 §3).
The path runs from the document's root: atoms or strings for keys, non-negative integers
for list positions. A key the document type does not know stays at its own spelling, a
string. Every fault is reported, never just the first, ordered by path (sort/1).
format/2 words a fault as path: words. The kernel words its own reasons; any other is
the document type's, given as words::
iex> Macaw.Layers.Fault.format({[:frames, "main", "wdth"], :unknown_key})
"frames.main.wdth: is not a key of this node"
iex> Macaw.Layers.Fault.format({[], {:newer_schema, 4, 3}}, root: "design")
"design: needs schema v4, this is v3"The formatter is visualize's Visualize.Chart.Validator.format/1 and the generic part of
its wording, with the root's name and the type's own wording as options.
Summary
Functions
A fault as path: words.
A path as a person reads it: keys joined by ., an index as [i], and the empty path
as the root's name.
Faults ordered by path, keeping the given order of faults at one path.
Types
format/2's options.
@type path() :: [atom() | String.t() | non_neg_integer()]
Where a fault is: keys and list positions from the document's root.
A fault: where, and why.
Functions
A fault as path: words.
Options:
root:the name of the empty path,"document"by default;words:a function that words the reasons the kernel does not. Without one, such a reason is shown withinspect/1.
A path as a person reads it: keys joined by ., an index as [i], and the empty path
as the root's name.
iex> Macaw.Layers.Fault.format_path([:marks, 0, :channels])
"marks[0].channels"
iex> Macaw.Layers.Fault.format_path([])
"document"
Faults ordered by path, keeping the given order of faults at one path.