enver v0.2.0 Enver.AtomParser

Link to this section Summary

Functions

Converts the given binary to an atom

Link to this section Types

Link to this type invalid()
invalid() :: Enver.invalid()
Link to this type valid()
valid() :: {:ok, atom()}

Link to this section Functions

Link to this function parse(val, opts)
parse(val(), opts()) :: valid() | invalid()

Converts the given binary to an atom.

iex(1)> Enver.AtomParser.parse("ok", %{type: :atom})
{:ok, :ok}

Options:

  • :allow_nonexistent

    • When false, the recommended setting, atoms that do not already exist will not be created, and an error will be returned
    • When true, the binary will be converted to an atom, creating a new atom if one did not already exist
    • To better understand the difference between existing & nonexistent atoms, read up on the differences betweeen &String.to_existing_atom/1 and &String.to_atom/1
    • Defaults to false