VBT (vbt v0.1.0) View Source

Common helper functions

Link to this section Summary

Functions

Converts a boolean into :ok | {:error, :unauthorized}.

Performs recursive merge of two maps.

Converts a boolean into :ok | {:error, reason}.

Link to this section Functions

Specs

authorize(boolean()) :: :ok | {:error, :unauthorized}

Converts a boolean into :ok | {:error, :unauthorized}.

Specs

deep_merge(map(), map()) :: map()

Performs recursive merge of two maps.

Example:

iex> map1 = %{a: 1, b: 2, c: %{d: 3}}
iex> map2 = %{a: 4, c: %{e: 5}, f: 6}
iex> VBT.deep_merge(map1, map2)
%{a: 4, b: 2, c: %{d: 3, e: 5}, f: 6}
Link to this function

validate(condition, error)

View Source

Specs

validate(boolean(), error) :: :ok | {:error, error} when error: var

Converts a boolean into :ok | {:error, reason}.