# How do i run custom predicate on passed value itself?

**URL:** <https://discourse.dry-rb.org/t/how-do-i-run-custom-predicate-on-passed-value-itself/754>\
**Category:** dry-validation\
**Created:** [April 9, 2019, 5:34pm UTC](https://discourse.dry-rb.org/t/how-do-i-run-custom-predicate-on-passed-value-itself/754 "2019-04-09T17:34:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nakuku](https://avatars.discourse-cdn.com/v4/letter/n/74df32/32.png) [@nakuku](https://discourse.dry-rb.org/u/nakuku)\
**Post date:** [April 9, 2019, 5:34pm UTC](https://discourse.dry-rb.org/t/how-do-i-run-custom-predicate-on-passed-value-itself/754/1 "2019-04-09T17:34:39Z")

</div>

Input is an array of zone objects - hashes with `name` and other fields. Zone itself must match certain schema but i want to check if all required zones were passed.

```auto
REQUIRED_ZONES = ["name", "date", "number"]

ZonesArraySchema = Dry::Validation.Schema do
  configure do
    def includes_required_zones?(zones)
      filled_zones = zones.pluck(:name) & REQUIRED_ZONES
      filled_zones.sort == REQUIRED_ZONES.sort
    end
  end

  includes_required_zones? # Perform it on array itself 

  each do
    schema(Schemas::Zone)
  end
end

```

I could perform this predicate one level up but i want it to be self-contained.  
Thank you!
