# `Macaw.Host.Config.Types`
[🔗](https://github.com/dcoai/macaw_host/blob/v0.1.4/lib/macaw/host/config/types.ex#L1)

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).

| Type | From the file | From an env var |
|---|---|---|
| `:string`, `:secret` | a string | as is |
| `:optional_string` | a string or `nil` | as is; empty is `nil` |
| `:boolean` | `true` or `false` | `true`, `false`, `1`, `0` |
| `:integer`, `:pos_integer`, `:port` | an integer in range | decimal digits |
| `{:enum, [atom]}` | one of the atoms | its name |
| `:string_list` | a list of strings | comma-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.

# `t`

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

# `cast`

```elixir
@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`

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

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

# `describe`

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

A type in words, for fault messages.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
