sparkpost v0.1.0 Washup

Tools for verifying and pruning Elixir structs before JSON serialisation.

Summary

Functions

Walk a possibly nested data structure, filtering out nil values

Walk a possibly nested data structure and raise an exception if a :required is found

Functions

filter(it)

Walk a possibly nested data structure, filtering out nil values.

Example

iex> jenny = %{name: "Jennifer", age: 27, rank: "Captain", pets: nil}
iex> Washup.filter(jenny)
%{name: "Jennifer", age: 27, rank: "Captain"}
iex> Washup.filter("Plain String")
"Plain String" 
verify(it, path \\ [])

Walk a possibly nested data structure and raise an exception if a :required is found.

Example

iex> jenny = %{name: "Jennifer", age: 27, rank: "Captain", pets: [%{species: :required}]}
iex> Washup.verify(jenny)
** (Washup.RequiredError) pets->listidx->species required