paramsx v0.4.2 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.
Important: You have to allow all params correctly, by default it allow only string or number for a simple key, if you want specify a keyword list with correct params like the last example.
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"}}
iex> Paramsx.filter(%{"foo" => %{"bar" => "value_bar"}}, required: [:foo])
{:error, %{missing_keys: [:foo]}}
iex> Paramsx.filter(%{"foo" => %{"bar" => "value_bar"}}, required: [foo: [:bar]])
{:ok, %{foo: %{bar: "value_bar"}}}
iex> Paramsx.filter(%{"foo" => [%{"bar" => "value_bar"}]}, required: [foo_list: [:bar]])
{:ok, %{foo: [%{bar: "value_bar"}]}}