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

"Object doesn't support #inspect" error raised while validating object that contains an array type attribute that contains the custom objects #380

Open
dawlib opened this issue Nov 16, 2021 · 0 comments

Comments

@dawlib
Copy link

dawlib commented Nov 16, 2021

Describe the bug

Object doesn't support #inspect error is raised when validating an object shown in the example below.

To Reproduce

require 'dry/schema'

module Types
  include Dry::Types()
end

class MyItem1 < Dry::Schema::JSON
  define do
    required(:name).filled(Types::String.enum(*%w[a]))
    optional(:time).filled(:time)
  end
end

class MyItem2 < Dry::Schema::JSON
  define do
    required(:name).filled(Types::String.enum(*%w[b]))
    optional(:time).filled(:time)
  end
end

class MyList < Dry::Schema::JSON
  define do
    required(:list).value(:array).each { MyItem1.new | MyItem2.new }
  end
end

item1 = { 'name' => 'a', 'time' => Time.now.iso8601 }
item2 = { 'name' => 'b', 'time' => Time.now.iso8601 }

MyItem1.new.call(item1).failure? # => false
MyItem2.new.call(item2).failure? # => false
MyList.new.call('list' => [item1, item2]).failure? # => true

MyList.new.call('list' => [item1, item2])
(Object doesn't support #inspect)
=>

Expected behavior

I would expect to receive a proper result of validation while executing the command below:

MyList.new.call('list' => [item1, item2])

My environment

  • Affects my production application: YES
  • dry-schema version: 1.8.0
  • Ruby version: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]
  • OS: macOS Monetery 12.0.1, Ubuntu 18.04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant