# How to use external depency methods in validations?

**URL:** <https://discourse.dry-rb.org/t/how-to-use-external-depency-methods-in-validations/115>\
**Category:** dry-validation\
**Created:** [September 21, 2016, 10:03pm UTC](https://discourse.dry-rb.org/t/how-to-use-external-depency-methods-in-validations/115 "2016-09-21T22:03:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stackus](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/stackus/32/56_2.png) [@stackus](https://discourse.dry-rb.org/u/stackus)\
**Post date:** [September 21, 2016, 10:03pm UTC](https://discourse.dry-rb.org/t/how-to-use-external-depency-methods-in-validations/115/1 "2016-09-21T22:03:37Z")

</div>

Using external dependencies that represent objects, how can you use the methods on that object in a validation?

Simple example

```
Dry::Validation.Schema do
  configure do
    option :record
  end

  required(:id, :int).filled(eql?: record.id)
end

# Throws Error: NoMethodError (undefined method `id' for #<UnboundMethod:0x007fce52b82c70>)
```

---

<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 22, 2016, 4:32am UTC](https://discourse.dry-rb.org/t/how-to-use-external-depency-methods-in-validations/115/2 "2016-09-22T04:32:18Z")

</div>

This should work:

```ruby
Dry::Validation.Schema do
  configure do
    config.type_specs = true
  end

  required(:id, :int).filled(:int?)

  validate(valid_record_id: %i[id]) do |id|
    id.equal?(record.id)
  end
end

```

This is a new feature in 0.10.0.
