is v1.0.0 Is.Validators.Map View Source

Validation for map.

Examples

iex> Is.validate(%{a: true}, :map)
[]

iex> Is.validate(%{a: true}, map: false)
[{:error, [], "must not be a map"}]

iex> Is.validate(%{a: true}, map: %{a: :boolean})
[]

iex> Is.validate(10, map: %{a: :binary})
[{:error, [], "map: data is not a map or options are invalid"}]

iex> Is.validate(%{a: true}, map: %{a: :binary})
[{:error, [:a], "must be a binary"}]

iex> Is.validate(%{a: "ok"}, map: %{a: :binary})
[]

iex> Is.validate(%{a: "ok"}, map: %{a: [binary: false]})
[{:error, [:a], "must not be a binary"}]

iex> Is.validate(%{a: %{b: %{c: true}}}, map: %{a: %{b: %{c: :boolean}}})
[]

iex> Is.validate(%{a: %{b: %{c: true}}}, map: %{a: [map: %{b: [map: %{c: :boolean}]}]})
[]

iex> Is.validate(%{a: %{b: %{c: true}}}, map: %{a: [map: %{b: [map: %{c: [boolean: false]}]}]})
[{:error, [:a, :b, :c], "must not be a boolean"}]

iex> Is.validate(%{a: %{b: %{c: true}}}, %{a: %{b: %{c: :binary}, d: :boolean}})
[{:error, [:a, :b, :c], "must be a binary"}, {:error, [:a, :d], "must be a boolean"}]

Link to this section Summary

Link to this section Functions