Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/nimble_options.ex
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ defmodule NimbleOptions do
{:ok, value}
end

defp validate_type(:mfa, key, value, redact) when not is_nil(value) do
defp validate_type(:mfa, key, value, redact) do
structured_error_tuple(key, value, "tuple {mod, fun, args}", inspect(value), redact)
end

Expand Down
16 changes: 16 additions & 0 deletions test/nimble_options_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,22 @@ defmodule NimbleOptionsTest do
}
end

test "mfa rejects nil" do
schema = [transformer: [type: :mfa]]

opts = [transformer: nil]

assert NimbleOptions.validate(opts, schema) == {
:error,
%ValidationError{
key: :transformer,
value: nil,
message:
"invalid value for :transformer option: expected tuple {mod, fun, args}, got: nil"
}
}
end

test "redacted invalid mfa" do
schema = [transformer: [type: :mfa, redact: true]]

Expand Down
Loading