mayo v0.2.0 Mayo.Map

Summary

Functions

Checks the number of the keys in the map

Checks the maximum number of the keys in the map

Checks the minimum number of the keys in the map

Rename a key to another name

Checks the presence of keys

Forbids the presence of keys

Functions

length(value, len)

Checks the number of the keys in the map.

iex> Mayo.Map.length(%{foo: "bar"}, 1)
%{foo: "bar"}

iex> Mayo.Map.length(%{}, 1)
{:error, %Mayo.Error{type: "map.length"}}
max(value, len)

Checks the maximum number of the keys in the map.

iex> Mayo.Map.max(%{foo: "bar"}, 1)
%{foo: "bar"}

iex> Mayo.Map.max(%{foo: "bar", baz: "boo"}, 1)
{:error, %Mayo.Error{type: "map.max"}}
min(value, len)

Checks the minimum number of the keys in the map.

iex> Mayo.Map.min(%{foo: "bar"}, 1)
%{foo: "bar"}

iex> Mayo.Map.min(%{}, 1)
{:error, %Mayo.Error{type: "map.min"}}
rename(value, from, to)

Rename a key to another name.

iex> Mayo.Map.rename(%{foo: "bar"}, :foo, :baz)
%{baz: "bar"}

iex> Mayo.Map.rename(%{foo: "bar"}, :bar, :baz)
%{foo: "bar"}
with(value, peers)

Checks the presence of keys.

iex> Mayo.Map.with(%{foo: "bar", baz: "boo"}, [:foo, :baz])
%{foo: "bar", baz: "boo"}

iex> Mayo.Map.with(%{foo: "bar"}, [:foo, :baz])
{:error, %Mayo.Error{type: "map.with", paths: [:baz]}}
without(value, peers)

Forbids the presence of keys.

iex> Mayo.Map.without(%{foo: "bar"}, [:baz, :boo])
%{foo: "bar"}

iex> Mayo.Map.without(%{foo: "bar", baz: "boo"}, [:baz, :boo])
{:error, %Mayo.Error{type: "map.without", paths: [:baz]}}