These are chat archives for dry-rb/chat

23rd
Apr 2017
Adam Gwozdowski
@agwozdowski
Apr 23 2017 19:26

Hi, I have simple configuration:

class App
  extend Dry::Configurable

  setting :redis do
    setting :url
  end

  setting :name
end

And validation schema:

ConfigurationSchema = Dry::Validation.Schema do
  required(:name).maybe(:str?)
  required(:redis).schema do
    required(:url).maybe(:str?)
  end
end

When I run:

ConfigurationSchema.(App.config.to_h).inspect

Receive error:
errors={:redis=>[\"must be a hash\"]}

Because to_h method doesn't change NestedConfig into hash. What is the best way to handle this case? Thanks for help!