# What am i doing wrong?

**URL:** <https://discourse.dry-rb.org/t/what-am-i-doing-wrong/1436>\
**Category:** Support\
**Created:** [March 3, 2022, 7:42pm UTC](https://discourse.dry-rb.org/t/what-am-i-doing-wrong/1436 "2022-03-03T19:42:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bugthing](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/bugthing/32/749_2.png) [@bugthing](https://discourse.dry-rb.org/u/bugthing)\
**Post date:** [March 3, 2022, 7:42pm UTC](https://discourse.dry-rb.org/t/what-am-i-doing-wrong/1436/1 "2022-03-03T19:42:40Z")

</div>

hello all 🙂

I am getting the following error

```bash
ruby/3.1.1/lib/ruby/gems/3.1.0/gems/dry-monads-1.4.0/lib/dry/monads/do/mixin.rb:49:in `block in bind': undefined method `to_monad' for #<Dry::Validation::Result{:name=>"dave"} errors={}> (NoMethodError)

            monad = result.to_monad

```

when I run this simple example

```ruby
#!/usr/bin/env ruby

require "bundler/inline"

gemfile do
  source "https://rubygems.org"
  gem "dry-validation", "~> 1.8"
  gem "dry-monads", "~> 1.4"
end

require "dry/validation"
require "dry/monads"
require "dry/monads/do"

class Command
  include Dry::Monads[:result]
  include Dry::Monads::Do.for(:call)

  def call(params)
    values = yield validate(params)
    name = yield do_something(values)

    Success(name)
  end

  def validate(params)
    Contract.new.call(params)
  end

  def do_something(values)
    returns Success(values.name)
  end
end

class Contract < Dry::Validation::Contract
  params do
    required(:name).filled(:string)
  end
end

result = Command.new.call(name: "dave")

puts "The name: #{result.value!}"

```

Knowing me I have skipped over or misread some docs… but I am abit stuck, could some please point out the problem with the code

thanks for reading my plead for help 😃

---

<div class="post-metadata">

**Author:** ![bkuhlmann](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/bkuhlmann/32/557_2.png) [@bkuhlmann](https://discourse.dry-rb.org/u/bkuhlmann)\
**Post date:** [March 3, 2022, 7:57pm UTC](https://discourse.dry-rb.org/t/what-am-i-doing-wrong/1436/2 "2022-03-03T19:57:21Z")

</div>

Hey Ben, you just need to load the monads extension for Dry Validation. Like this:

```ruby
Dry::Validation.load_extensions :monads

```

You’ll also want to fix this method as follows:

```ruby
def do_something(values) = Success(values[:name])

```

Now, when you run the script, it’ll work.

---

<div class="post-metadata">

**Author:** ![bugthing](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/bugthing/32/749_2.png) [@bugthing](https://discourse.dry-rb.org/u/bugthing)\
**Post date:** [March 3, 2022, 9:17pm UTC](https://discourse.dry-rb.org/t/what-am-i-doing-wrong/1436/3 "2022-03-03T21:17:40Z")

</div>

arh! amazing, thanks so much.
