Macaw.Host.Config.Types (macaw_host v0.1.4)

Copy Markdown View Source

The setting types Macaw.Host.Config understands, and how a value of each is read from an environment variable (a string) or checked from config.exs (a literal).

TypeFrom the fileFrom an env var
:string, :secreta stringas is
:optional_stringa string or nilas is; empty is nil
:booleantrue or falsetrue, false, 1, 0
:integer, :pos_integer, :portan integer in rangedecimal digits
{:enum, [atom]}one of the atomsits name
:string_lista list of stringscomma-separated
{:custom, {m, f}}m.f(value) returns {:ok, v} or {:error, message}the same, given the string

A :secret is masked wherever a value is shown (Macaw.Host.Config.show/1, Macaw.Host.Config.mask/2). Enum names from env vars are compared as strings, so no atom is made.

Summary

Functions

Reads a value from an env var's string: {:ok, value} or {:error, why}.

Checks a value from config.exs: {:ok, value} or {:error, why}.

A type in words, for fault messages.

Types

t()

@type t() ::
  :string
  | :secret
  | :optional_string
  | :boolean
  | :integer
  | :pos_integer
  | :port
  | {:enum, [atom()]}
  | :string_list
  | {:custom, {module(), atom()}}

Functions

cast(type, text)

@spec cast(t(), String.t()) :: {:ok, term()} | {:error, String.t()}

Reads a value from an env var's string: {:ok, value} or {:error, why}.

check(type, value)

@spec check(t(), term()) :: {:ok, term()} | {:error, String.t()}

Checks a value from config.exs: {:ok, value} or {:error, why}.

describe(arg1)

@spec describe(t()) :: String.t()

A type in words, for fault messages.