Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type? should support any available class #223

Closed
rosskevin opened this issue Jul 27, 2016 · 7 comments
Closed

type? should support any available class #223

rosskevin opened this issue Jul 27, 2016 · 7 comments
Labels
Milestone

Comments

@rosskevin
Copy link

Given I have a class named Acme::Catalog
When I use required(:catalog).value(type?: Catalog) within module Acme
Then it should validate that catalog.is_a? Acme::Catalog

Currently I get Nothing registered with the key "acme.catalog" (Dry::Container::Error)

@solnic solnic added this to the 0.10.0 milestone Jul 31, 2016
@solnic
Copy link
Member

solnic commented Sep 5, 2016

This is working on master now. Closing...

@dikond
Copy link

dikond commented Feb 21, 2017

Hi! I'm experiencing the same problem, I believe.

Here is the validation:

require 'core/validation/form'

module App::Shared
  module Validations
    FormDataFile = Core::Validation.Form do
      required(:filename).filled(:str?)
      required(:type).filled(:str?)
      required(:tempfile).value(type?: File) # { filled? & type?(File) }
      optional(:head).filled(:str?)
    end
  end
end

Note: Core::Validation.Form is our wrapper that provides some common configuration. If I change the Core::Validation.Form to Dry::Validation.Form result would be the same.

Here is the part of a backtrace that may help:

Dry::Container::Error: Nothing registered with the key "file"
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-container-0.6.0/lib/dry/container/resolver.rb:22:in `block in call'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-container-0.6.0/lib/dry/container/resolver.rb:21:in `fetch'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-container-0.6.0/lib/dry/container/resolver.rb:21:in `call'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-container-0.6.0/lib/dry/container/mixin.rb:112:in `resolve'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-container-0.6.0/lib/dry/container/mixin.rb:125:in `[]'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-types-0.9.4/lib/dry/types.rb:82:in `block in []'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.4/lib/concurrent/map.rb:133:in `block in fetch_or_store'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.4/lib/concurrent/map.rb:122:in `fetch'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.4/lib/concurrent/map.rb:132:in `fetch_or_store'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-types-0.9.4/lib/dry/types.rb:73:in `[]'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-types-0.9.4/lib/dry/types/compiler.rb:30:in `visit_type'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-types-0.9.4/lib/dry/types/compiler.rb:15:in `visit'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-types-0.9.4/lib/dry/types/compiler.rb:75:in `visit_key'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-types-0.9.4/lib/dry/types/compiler.rb:15:in `visit'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-types-0.9.4/lib/dry/types/compiler.rb:80:in `block in merge_with'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-types-0.9.4/lib/dry/types/compiler.rb:80:in `map'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-types-0.9.4/lib/dry/types/compiler.rb:80:in `merge_with'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-types-0.9.4/lib/dry/types/compiler.rb:58:in `visit_form_hash'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-types-0.9.4/lib/dry/types/compiler.rb:28:in `visit_type'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-types-0.9.4/lib/dry/types/compiler.rb:15:in `visit'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-types-0.9.4/lib/dry/types/compiler.rb:11:in `call'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-validation-0.10.5/lib/dry/validation/input_processor_compiler.rb:16:in `call'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-validation-0.10.5/lib/dry/validation/schema/deprecated.rb:14:in `input_processor'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-validation-0.10.5/lib/dry/validation/schema/class_interface.rb:164:in `default_options'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-validation-0.10.5/lib/dry/validation/schema/class_interface.rb:35:in `new'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-validation-0.10.5/lib/dry/validation.rb:23:in `Schema'
  /Users/danny/dev/enbro_crm/lib/core/validation/form.rb:75:in `Form'
  /Users/danny/dev/enbro_crm/lib/app/shared/validations/form_data_file.rb:5:in `<module:Validations>'
  /Users/danny/dev/enbro_crm/lib/app/shared/validations/form_data_file.rb:4:in `<module:Shared>'
  /Users/danny/dev/enbro_crm/lib/app/shared/validations/form_data_file.rb:3:in `<top (required)>'
  /Users/danny/dev/enbro_crm/lib/app/suppliers/operations/import_prices.rb:2:in `require'
  /Users/danny/dev/enbro_crm/lib/app/suppliers/operations/import_prices.rb:2:in `<top (required)>'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/dry-system-bd16cd842756/lib/dry/system/lifecycle.rb:99:in `require'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/dry-system-bd16cd842756/lib/dry/system/lifecycle.rb:99:in `public_send'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/dry-system-bd16cd842756/lib/dry/system/lifecycle.rb:99:in `method_missing'
  /Users/danny/dev/enbro_crm/system/boot/operations.rb:5:in `block (2 levels) in <top (required)>'
  /Users/danny/dev/enbro_crm/system/boot/operations.rb:4:in `each'
  /Users/danny/dev/enbro_crm/system/boot/operations.rb:4:in `block in <top (required)>'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/dry-system-bd16cd842756/lib/dry/system/lifecycle.rb:43:in `instance_exec'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/dry-system-bd16cd842756/lib/dry/system/lifecycle.rb:43:in `initialize'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/dry-system-bd16cd842756/lib/dry/system/lifecycle.rb:29:in `new'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/dry-system-bd16cd842756/lib/dry/system/lifecycle.rb:29:in `block in new'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.4/lib/concurrent/map.rb:133:in `block in fetch_or_store'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.4/lib/concurrent/map.rb:122:in `fetch'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.4/lib/concurrent/map.rb:132:in `fetch_or_store'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/dry-system-bd16cd842756/lib/dry/system/lifecycle.rb:28:in `new'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/dry-system-bd16cd842756/lib/dry/system/booter.rb:70:in `call'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/dry-system-bd16cd842756/lib/dry/system/booter.rb:45:in `boot'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/dry-system-bd16cd842756/lib/dry/system/booter.rb:59:in `boot!'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/dry-system-bd16cd842756/lib/dry/system/container.rb:268:in `boot!'
  /Users/danny/dev/enbro_crm/system/boot.rb:20:in `block in <top (required)>'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/dry-system-bd16cd842756/lib/dry/system/container.rb:246:in `finalize!'
  /Users/danny/dev/enbro_crm/system/boot.rb:4:in `<top (required)>'
  /Users/danny/dev/enbro_crm/config/system.rb:9:in `require_relative'
  /Users/danny/dev/enbro_crm/config/system.rb:9:in `<top (required)>'
  /Users/danny/dev/enbro_crm/config/environment.rb:2:in `require_relative'
  /Users/danny/dev/enbro_crm/config/environment.rb:2:in `<top (required)>'
  /Users/danny/dev/enbro_crm/spec/spec_helper.rb:16:in `require_relative'
  /Users/danny/dev/enbro_crm/spec/spec_helper.rb:16:in `<top (required)>'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1394:in `require'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1394:in `block in requires='
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1394:in `each'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1394:in `requires='
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration_options.rb:112:in `block in process_options_into'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration_options.rb:111:in `each'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration_options.rb:111:in `process_options_into'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration_options.rb:21:in `configure'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:99:in `setup'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:86:in `run'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:71:in `run'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:45:in `invoke'
  /Users/danny/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/exe/rspec:4:in `<top (required)>'
  /Users/danny/.rbenv/versions/2.4.0/bin/rspec:22:in `load'
  /Users/danny/.rbenv/versions/2.4.0/bin/rspec:22:in `<top (required)>'

@bewitchingme
Copy link

I am using Dry validation with Reform, and I also experience this bug:

module Admin::Coupon::Contract
  class Create < Reform::Form
    feature Dry

    property :code
    property :name
    property :effective_from
    property :effective_to
    property :auto_apply, populator: :populate_auto_apply!
    property :city
    property :region
    property :usage_limit, populator: :populate_usage_limit!
    property :usage_maximum, populator: :populate_usage_maximum!
    property :discount_type
    property :discount_percentage
    property :discount_amount
    property :genre, populator: :populate_genre!
    property :sub_genre, populator: :populate_sub_genre!
    property :hyper_genre, populator: :populate_hyper_genre!
    property :visibility
    property :user_name, virtual: true
    property :user, populator: :populate_user!
    property :license_for_podcast

    def populate_usage_limit!(fragment:, **)
      self.usage_limit = fragment.to_i unless fragment.nil?
    end

    def populate_usage_maximum!(fragment:, **)
      self.usage_maximum = fragment.to_i unless fragment.nil?
    end

    def populate_auto_apply!(fragment:, **)
      self.auto_apply = true  if fragment.eql? '1'
      self.auto_apply = false if fragment.eql? '0'
    end

    def populate_genre!(fragment:, **)
      self.genre = Genre.find(fragment) unless fragment.nil? or fragment.to_i == 0
    end

    def populate_sub_genre!(fragment:, **)
      self.sub_genre = SubGenre.find(fragment) unless fragment.nil? or fragment.to_i == 0
    end

    def populate_hyper_genre!(fragment:, **)
      self.hyper_genre = HyperGenre.find(fragment) unless fragment.nil? or fragment.to_i == 0
    end

    def populate_user!(fragment:, **)
      self.user = User.find(fragment) unless fragment.nil? or fragment.to_i == 0
    end

    validation :default do
      configure do
        option :form

        config.messages_file = 'config/errors.yml'

        def discount_types
          %w(percentage currency) + %i(percentage currency)
        end

        def visibility_types
          %w(visible invisible) + %i(visible invisible)
        end

        def license_for_podcast_types
          %w(yes no any) + %i(yes no any)
        end
      end

      required(:code).filled(:str?, min_size?: 4, max_size?: 10)
      required(:name).filled(:str?, max_size?: 255)
      required(:effective_from).filled(:date?)
      required(:effective_to).filled(:date?)
      required(:auto_apply).filled(:bool?)
      required(:city).maybe(:str?)
      required(:region).maybe(:str?)
      required(:usage_limit).filled(:int?, min_size?: 0, max_size?: 20000)
      required(:usage_maximum).maybe
      required(:discount_type).filled(:str?, included_in?: discount_types)
      required(:discount_percentage).maybe
      required(:discount_amount).maybe
      required(:genre).maybe(type?: ::Genre)
      required(:sub_genre).maybe(type?: ::SubGenre)
      required(:hyper_genre).maybe(type?: ::HyperGenre)
      required(:visibility).filled(:str?, included_in?: visibility_types)
      required(:user).filled(type?: ::User)
      required(:license_for_podcast).filled(:str?, included_in?: license_for_podcast_types)
    end
  end
end

Full trace:

Testing started at 2:49 PM ...
/home/rpc/.rubies/ruby-2.4.1/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /home/rpc/.rubies/ruby-2.4.1/bin/rspec /home/rpc/Projects/Rails/earshot_dds/spec/operations/coupon/create_spec.rb --require teamcity/spec/runner/formatter/teamcity/formatter --format Spec::Runner::Formatter::TeamcityFormatter --example Coupon::Create --backtrace
[Disposable] The Struct module is deprecated, please use Property::Struct.

An error occurred while loading ./spec/operations/coupon/create_spec.rb.
Failure/Error:
      validation :default do
        configure do
          option :form
  
          config.messages_file = 'config/errors.yml'
  
          def discount_types
            %w(percentage currency) + %i(percentage currency)
          end
  

Dry::Container::Error:
  Nothing registered with the key "genre"
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-container-0.6.0/lib/dry/container/resolver.rb:22:in `block in call'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-container-0.6.0/lib/dry/container/resolver.rb:21:in `fetch'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-container-0.6.0/lib/dry/container/resolver.rb:21:in `call'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-container-0.6.0/lib/dry/container/mixin.rb:112:in `resolve'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-container-0.6.0/lib/dry/container/mixin.rb:125:in `[]'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-types-0.10.3/lib/dry/types.rb:83:in `block in []'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:133:in `block in fetch_or_store'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:122:in `fetch'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:132:in `fetch_or_store'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-types-0.10.3/lib/dry/types.rb:74:in `[]'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-types-0.10.3/lib/dry/types/compiler.rb:30:in `visit_type'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-types-0.10.3/lib/dry/types/compiler.rb:15:in `visit'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-types-0.10.3/lib/dry/types/compiler.rb:35:in `block in visit_sum'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-types-0.10.3/lib/dry/types/compiler.rb:35:in `map'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-types-0.10.3/lib/dry/types/compiler.rb:35:in `visit_sum'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-types-0.10.3/lib/dry/types/compiler.rb:15:in `visit'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-types-0.10.3/lib/dry/types/compiler.rb:75:in `visit_key'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-types-0.10.3/lib/dry/types/compiler.rb:15:in `visit'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-types-0.10.3/lib/dry/types/compiler.rb:80:in `block in merge_with'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-types-0.10.3/lib/dry/types/compiler.rb:80:in `map'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-types-0.10.3/lib/dry/types/compiler.rb:80:in `merge_with'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-types-0.10.3/lib/dry/types/compiler.rb:58:in `visit_form_hash'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-types-0.10.3/lib/dry/types/compiler.rb:28:in `visit_type'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-types-0.10.3/lib/dry/types/compiler.rb:15:in `visit'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-types-0.10.3/lib/dry/types/compiler.rb:11:in `call'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-validation-0.10.7/lib/dry/validation/input_processor_compiler.rb:16:in `call'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-validation-0.10.7/lib/dry/validation/schema/deprecated.rb:14:in `input_processor'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-validation-0.10.7/lib/dry/validation/schema/class_interface.rb:165:in `default_options'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-validation-0.10.7/lib/dry/validation/schema/class_interface.rb:35:in `new'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-validation-0.10.7/lib/dry/validation.rb:23:in `Schema'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/dry-validation-0.10.7/lib/dry/validation.rb:29:in `Form'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/reform-2.2.4/lib/reform/form/dry.rb:48:in `initialize'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/reform-2.2.4/lib/reform/form/dry.rb:33:in `new'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/reform-2.2.4/lib/reform/form/dry.rb:33:in `instance_exec'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/reform-2.2.4/lib/reform/validation.rb:15:in `validation'
# ./app/concepts/admin/coupon/contract/create.rb:56:in `<class:Create>'
# ./app/concepts/admin/coupon/contract/create.rb:4:in `<module:Contract>'
# ./app/concepts/admin/coupon/contract/create.rb:3:in `<top (required)>'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:292:in `require'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:292:in `block in require'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:258:in `load_dependency'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:292:in `require'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:379:in `block in require_or_load'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:36:in `block in load_interlock'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/concurrency/share_lock.rb:149:in `exclusive'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/dependencies/interlock.rb:11:in `loading'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:36:in `load_interlock'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:357:in `require_or_load'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:335:in `depend_on'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:251:in `require_dependency'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/trailblazer-rails-1.0.2/lib/trailblazer/rails/railtie.rb:19:in `block in load_for'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/trailblazer-loader-0.1.1/lib/trailblazer/loader.rb:75:in `block in load_files'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/trailblazer-loader-0.1.1/lib/trailblazer/loader.rb:75:in `each'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/trailblazer-loader-0.1.1/lib/trailblazer/loader.rb:75:in `load_files'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/trailblazer-loader-0.1.1/lib/trailblazer/loader.rb:38:in `call'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/trailblazer-rails-1.0.2/lib/trailblazer/rails/railtie.rb:19:in `load_for'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/trailblazer-rails-1.0.2/lib/trailblazer/rails/railtie.rb:11:in `load_concepts'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/trailblazer-rails-1.0.2/lib/trailblazer/rails/railtie.rb:31:in `block (2 levels) in <class:Railtie>'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/callbacks.rb:413:in `instance_exec'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/callbacks.rb:413:in `block in make_lambda'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/callbacks.rb:197:in `block (2 levels) in halting'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/callbacks.rb:601:in `block (2 levels) in default_terminator'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/callbacks.rb:600:in `catch'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/callbacks.rb:600:in `block in default_terminator'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/callbacks.rb:198:in `block in halting'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/callbacks.rb:507:in `block in invoke_before'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/callbacks.rb:507:in `each'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/callbacks.rb:507:in `invoke_before'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/callbacks.rb:130:in `run_callbacks'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/reloader.rb:87:in `prepare!'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.1/lib/rails/application/finisher.rb:61:in `block in <module:Finisher>'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.1/lib/rails/initializable.rb:30:in `instance_exec'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.1/lib/rails/initializable.rb:30:in `run'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.1/lib/rails/initializable.rb:59:in `block in run_initializers'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:228:in `block in tsort_each'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:431:in `each_strongly_connected_component_from'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:349:in `block in each_strongly_connected_component'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:347:in `each'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:347:in `call'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:347:in `each_strongly_connected_component'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.1/lib/rails/initializable.rb:58:in `run_initializers'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.1/lib/rails/application.rb:353:in `initialize!'
# ./config/environment.rb:5:in `<top (required)>'
# ./spec/rails_helper.rb:3:in `require'
# ./spec/rails_helper.rb:3:in `<top (required)>'
# ./spec/operations/coupon/create_spec.rb:1:in `require'
# ./spec/operations/coupon/create_spec.rb:1:in `<top (required)>'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/configuration.rb:1922:in `load'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/configuration.rb:1922:in `load_spec_file_handling_errors'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/configuration.rb:1494:in `block in load_spec_files'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/configuration.rb:1492:in `each'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/configuration.rb:1492:in `load_spec_files'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:100:in `setup'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:86:in `run'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:71:in `run'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:45:in `invoke'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/exe/rspec:4:in `<top (required)>'
# /home/rpc/.rubies/ruby-2.4.1/bin/rspec:22:in `load'
# /home/rpc/.rubies/ruby-2.4.1/bin/rspec:22:in `<top (required)>'
# -e:1:in `load'
# -e:1:in `<main>'
Run options: include {:full_description=>/Coupon::Create/}

All examples were filtered out

An error occurred in a `before(:suite)` hook.
Failure/Error: if config.use_transactional_fixtures?

NoMethodError:
  undefined method `use_transactional_fixtures?' for #<RSpec::Core::Configuration:0x00563ec9db1f88>
# ./spec/spec_helper.rb:42:in `block (2 levels) in <top (required)>'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/example.rb:447:in `instance_exec'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/example.rb:447:in `instance_exec'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/hooks.rb:350:in `run'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/configuration.rb:1949:in `block in run_suite_hooks'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/configuration.rb:1947:in `each'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/configuration.rb:1947:in `run_suite_hooks'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/configuration.rb:1893:in `with_suite_hooks'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:113:in `block in run_specs'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/reporter.rb:79:in `report'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:112:in `run_specs'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:87:in `run'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:71:in `run'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:45:in `invoke'
# /home/rpc/.rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/exe/rspec:4:in `<top (required)>'
# /home/rpc/.rubies/ruby-2.4.1/bin/rspec:22:in `load'
# /home/rpc/.rubies/ruby-2.4.1/bin/rspec:22:in `<top (required)>'
# -e:1:in `load'
# -e:1:in `<main>'

0 examples, 0 failures, 0 passed

Finished in 0.014055391 seconds

Process finished with exit code 1
Empty test suite.

Using: dry-validation 0.10.7

@tylerhunt
Copy link

I ran into this on 0.12.1 today. Any updates or workarounds?

Should this issue be bumped to a different newer milestone?

/cc @flash-gordon

@flash-gordon
Copy link
Member

@tylerhunt yeah, I think something like this should work

module Types
  include Dry::Types.module
end

Schema = Dry::Validation.Schema do
  required(:foo).filled(Types::Instance(DateTime).constrained(lt: DateTime.now))
end

@tylerhunt
Copy link

@flash-gordon Your example works for certain built-in types like DateTime, but I still get the Nothing registered with the key error when using a custom Dry::Struct class. This only appears to be an issue when using the .Params schema generator (I don't see an error when using .Schema).

Here's a minimal case to reproduce:

require 'dry-struct'
require 'dry-types'
require 'dry-validation'

module Types
  include Dry::Types.module
end

class Custom < Dry::Struct
  attribute :value, Types::Coercible::Integer
end

Dry::Validation.Params do
  required(:custom).filled(Types.Instance(Custom))
end

Should this case work, or are custom types like this not supported with Schema::Params?

@flash-gordon
Copy link
Member

This will work fine in the next release with the type? predicate, as in,

required(:custom).filled(type?: Custom)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants