# Calling contracts on an array attribute

**URL:** <https://discourse.dry-rb.org/t/calling-contracts-on-an-array-attribute/1623>\
**Category:** dry-validation\
**Created:** [March 8, 2023, 11:21am UTC](https://discourse.dry-rb.org/t/calling-contracts-on-an-array-attribute/1623 "2023-03-08T11:21:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Renaud](https://avatars.discourse-cdn.com/v4/letter/r/dc4da7/32.png) [@Renaud](https://discourse.dry-rb.org/u/Renaud)\
**Post date:** [March 8, 2023, 11:21am UTC](https://discourse.dry-rb.org/t/calling-contracts-on-an-array-attribute/1623/1 "2023-03-08T11:21:22Z")

</div>

Hello,  
I was tasked with updating an old project (dry-validation 0.12) and I’m quite confused on how to adapt this specific piece of code :

```auto
  required(:materials).each do
    schema(Material.validation_schema)
  end

```

This was quite handy, but now validation\_schema is a Contract not a Schema as I tried to preserve the code structure (I do need to rename them), so schema(Material.validation\_schema) no longer works and I’m not sure how to achieve this with Contracts.

Thanks!

---

<div class="post-metadata">

**Author:** ![alassek](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/alassek/32/314_2.png) [@alassek](https://discourse.dry-rb.org/u/alassek)\
**Post date:** [March 9, 2023, 5:36pm UTC](https://discourse.dry-rb.org/t/calling-contracts-on-an-array-attribute/1623/2 "2023-03-09T17:36:51Z")

</div>

dry-validation was split into two projects, adding dry-schema as a separate thing. So a validation contract is an enclosing object around a Dry::Schema.

If you do not need the features of a contract, you can use [schema objects](https://dry-rb.org/gems/dry-schema/1.10/) directly. If you wish to keep them as contracts, you can access the internal schema from the `.schema` class method.

There [was an attempt](https://github.com/dry-rb/dry-validation/pull/595) to make contracts directly composable, but that is not yet supported.
