paramsx v0.2.0 Paramsx View Source
Paramsx provides functionally to whitelist and validate parameters
Link to this section Summary
Functions
Filter params based on your required and optional keyword.
Link to this section Functions
Filter params based on your required and optional keyword.
Examples
iex> Paramsx.filter(%{"foo" => "bar", "foo2" => "bar2"}, required: [:foo])
{:ok, %{foo: "bar"}}
iex> Paramsx.filter(%{"foo" => "bar", "foo2" => "bar2"}, required: [:foo3])
{:error, %{missing_keys: [:foo3]}}
iex> Paramsx.filter(%{"foo" => "bar", "foo2" => "bar2"}, required: [:foo], optional: [:foo3])
{:ok, %{foo: "bar"}}
Dont allow params list if it's not specified authorize only string and number
iex> Paramsx.filter(%{"foo" => %{"bar" => "value_bar"}}, required: [:foo]) {:ok, %{}}
iex> Paramsx.filter(%{"foo" => %{"bar" => "value_bar"}}, required: [foo: [:bar]]) {:ok, %{foo: %{bar: "value_bar"}}}