dry-rb / dry-rb/dry-initializer

Incorrect processing of nil value for array with nested structure

Open
#108 3 comments 0 reactions 0 assignees View on GitHub
bug help wanted
Dominant language
Ruby
Stars
342
Forks
42
PR merge metrics
No merged PRs in 30d

Description

## Describe the bug

I get a `KeyError` when pass the `nil` value for option, but it's ok when the option is omitted

## To Reproduce

```ruby
class X
extend Dry::Initializer

option :fields, [], optional: true, default: proc { [] } do
option :name
end
end

X.new #=> #
X.new(fields: []) #=> #
X.new(fields: nil) #=> KeyError (X::Fields: option 'name' is required)
```

## Expected behavior

Getting and empty array

## My environment

- Ruby version: 2.7.5
- OS: Linux
- dry-initializer (3.1.1)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.