A closed vocabulary read from a string (spec/01 §2).
A table maps each member's spelling to the member, built from the vocabulary's own list.
A reader looks a document's string up in it and never makes an atom of one. Nor does it
ask the node whether such an atom exists (String.to_existing_atom/1), which would let a
document probe the atom table and make a read depend on which modules are loaded. A
string the table lacks is the caller's to refuse at its path.
Build a table once, in a module attribute, wherever the list is known at compile time:
@anchors Vocabulary.table([:title, :subtitle, :caption])
Vocabulary.fetch(@anchors, "title") #=> {:ok, :title}
Vocabulary.fetch(@anchors, "footer") #=> :errorPorted from visualize's Visualize.Vocabulary.
Summary
Functions
The member a string spells, from a table or, for a list known only at run time and a few
members long, from the list itself. Anything that is not a string is :error.
The member a string spells, or the string itself: a value a validator then refuses by type at its path.
The table of a list of atoms.
Types
Functions
The member a string spells, from a table or, for a list known only at run time and a few
members long, from the list itself. Anything that is not a string is :error.
The member a string spells, or the string itself: a value a validator then refuses by type at its path.
The table of a list of atoms.