You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Types.Interface only returns an error, if the second method in the list is missing, while not in case of first method missing.
Let's say, I have an interface with :foo and :bar.
Then In case of having two classes, one implementing foo, and other implementing bar only, then in both scenarios dry-schema should return errors, as dry-types rises errors in both cases.
To Reproduce
# frozen_string_literal: truerequire'faker'classAdapter1defcall10.times.map{Faker::Name.name}endendclassAdapter2defcheck_connectiontrueendendclassAdapter3defcall10.times.map{Faker::Name.name}enddefcheck_connectiontrueendend# Defines Interface type requireing 2 methods to be implemented.#require'dry/types'moduleTypesincludeDry::Types()endAdapter=Types.Interface(:call,:check_connection)# Checks if dry-types behaves as expected# Should fail, only call check_connection method implementedbeginAdapter.call(Adapter1.new)rescueStandardErrorpp"Adapter1 failed"end# Should fail, only check_connection method implementedbeginAdapter.call(Adapter2.new)rescueStandardErrorpp"Adapter2 failed"end# This should not fail, both methods implementedbeginAdapter.call(Adapter3.new)rescueStandardErrorpp"Adapter3 failed"endrequire'dry/schema'classImporterdefcallendprivateattr_reader:providers,:schemadefinitialize(*args)schema=Dry::Schema.Paramsdorequired(:providers).filled(:array?).each(Adapter)endpp'-----'ppschema.call(*args)endendppImporter.new(providers: [Adapter1.new,Adapter2.new,Adapter3.new]).inspect# => #<Dry::Schema::Result{# :providers=>[#<Adapter1:0x00007fdf0b162aa0>, #<Adapter2:0x00007fdf0b162a78>, #<Adapter3:0x00007fdf0b162a50>]}# errors={:providers=>{0=>["must respond to check_connection"]}} path=[]># As you can see, only first adapter is reported as invalid, while the second should also be included here
Expected behavior
From the script above, I expect Adapter1 AND Adapter2 to be returned with errors.
My environment
Affects my production application: NO
Ruby version: 2.7.2
OS: MacOS
The text was updated successfully, but these errors were encountered:
Describe the bug
Types.Interface
only returns an error, if the second method in the list is missing, while not in case of first method missing.Let's say, I have an interface with
:foo
and:bar
.Then In case of having two classes, one implementing
foo
, and other implementingbar
only, then in both scenariosdry-schema
should return errors, as dry-types rises errors in both cases.To Reproduce
Expected behavior
From the script above, I expect
Adapter1
ANDAdapter2
to be returned with errors.My environment
The text was updated successfully, but these errors were encountered: