# Bug with \`maybe(:array).each\`

**URL:** <https://discourse.dry-rb.org/t/bug-with-maybe-array-each/1293>\
**Category:** Support\
**Created:** [July 2, 2021, 3:02pm UTC](https://discourse.dry-rb.org/t/bug-with-maybe-array-each/1293 "2021-07-02T15:02:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adamransom](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/adamransom/32/580_2.png) [@adamransom](https://discourse.dry-rb.org/u/adamransom)\
**Post date:** [July 2, 2021, 3:02pm UTC](https://discourse.dry-rb.org/t/bug-with-maybe-array-each/1293/1 "2021-07-02T15:02:41Z")

</div>

Hey,

I had a quick search and couldn’t see this bug mentioned before.

We’ve been trying to the use the following in our schemas:

```auto
required(:foo).maybe(:array).each(:integer)

```

However, when using input such as `{ foo: nil }` an exception will be raised around trying to call `.map` on `nil`.

Are you aware of this bug or shall I raise an issue on GitHub with a proper reproduction?

For now, we’ve had to do the following:

```auto
required(:foo).maybe(Types::Array.of(Types::Params::Integer))

```

Is there a better workaround?

---

<div class="post-metadata">

**Author:** ![solnic](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/solnic/32/779_2.png) [@solnic](https://discourse.dry-rb.org/u/solnic)\
**Post date:** [July 21, 2021, 6:05am UTC](https://discourse.dry-rb.org/t/bug-with-maybe-array-each/1293/2 "2021-07-21T06:05:12Z")

</div>

@adamransom sorry for late reply. This does look like a bug - please report it. A shorter workaround would be to do `schema { required(:foo).maybe(array[:integer]) }`
