Hi,

WDYT about adding a `strict: boolean` option to `Keyword.validate/2` that 
would make it return an error if a key that doesn't have a default value 
provided is absent? The returned value in case of an error could be 
`{:error, unknown_keys, missing_keys}`, for example:

{:error, [], [:b]} = Keyword.validate([a: :foo], [:a, :b], strict: true)
{:error, [:c], [:b]} = Keyword.validate([a: :foo, c: :bar], [:a, :b], 
strict: true)
{:error, [:c], []} = Keyword.validate([a: :foo, b: :foobar, c: :bar], [:a, 
:b], strict: true)

in case of success, the result would remain as it is now:

{:ok, [a: :foo, b: :bar]} = Keyword.validate([a: :foo, b: :bar], [:a, :b], 
strict: true)
{:ok, [b: :bar, a: :foo]} = Keyword.validate([a: :foo], [:a, b: :bar], 
strict: true)

The behaviour would be unchanged when the strict is set to false (default). 
The bang version would be adjusted accordingly.

Thanks ;)

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/44d14235-d129-4f1c-b9de-7895c610d083n%40googlegroups.com.

Reply via email to