# Combining min\_size? and each

**URL:** <https://discourse.dry-rb.org/t/combining-min-size-and-each/343>\
**Category:** dry-validation\
**Created:** [September 20, 2017, 9:43am UTC](https://discourse.dry-rb.org/t/combining-min-size-and-each/343 "2017-09-20T09:43:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![theozaurus](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/theozaurus/32/33_2.png) [@theozaurus](https://discourse.dry-rb.org/u/theozaurus)\
**Post date:** [September 20, 2017, 9:43am UTC](https://discourse.dry-rb.org/t/combining-min-size-and-each/343/1 "2017-09-20T09:43:49Z")

</div>

Hi All,

I’m attempting to make a validation that checks an array is a certain size, and also the contents of the array is correct.

For example:

```auto
Dry::Validation.Schema do
  required(:people).filled(min_size?: 10).each do
    required(:name) { filled? & str? }
  end
end

```

I’ve tried a number of different ways of specifying this. However, I can only ever get either min\_size to report an error (and when correctly sized does not report an error for a missing name - or have the minimum size ignored, but the name rule obeyed.

What’s the proper way to do this?

Thanks,

Theo

---

<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:** [September 20, 2017, 11:25am UTC](https://discourse.dry-rb.org/t/combining-min-size-and-each/343/2 "2017-09-20T11:25:02Z")

</div>

Something like this should work:

```ruby
Dry::Validation.Schema do
  required(:people).value(:array?, min_size?: 10) do
    each do
      schema do
        required(:name).filled(:str?)
      end
    end
  end
end

```

Hope this helps.
