pagination.ex: Drop atom keys in params

Atom keys could also have been transformed to string, or the other
way around but this one is more efficient and what we actually
expect with the current param_types in Pagination
This commit is contained in:
Haelwenn (lanodan) Monnier 2019-03-26 00:07:33 +01:00
parent 6f15224053
commit e83ad12c57
No known key found for this signature in database
GPG key ID: D5B7A8E43C997DEE

View file

@ -36,6 +36,12 @@ defp cast_params(params) do
limit: :integer
}
params =
Enum.reduce(params, %{}, fn
{key, _value}, acc when is_atom(key) -> Map.drop(acc, [key])
{key, value}, acc -> Map.put(acc, key, value)
end)
changeset = cast({%{}, param_types}, params, Map.keys(param_types))
changeset.changes
end