Invalid coercing for dry-validations?

Hello everyone,
I’m having some problems while doing some nested validations. I’m not entirely sure why my custom type is not applied for nested schema (it seems that the value is treat like default Types::Bool only) :frowning:

dry-validation (1.2.1)

module Types
  include Dry.Types()

  Coercible::Bool = Types::Bool.constructor { |value| ActiveRecord::Type::Boolean.new.serialize(value) }
end


class Validator < Dry::Validation::Contract
  params do
    required(:checked).value(Types::Coercible::Bool)
    required(:collection).each do
      schema do
        required(:checked).value(Types::Coercible::Bool)
      end
    end
  end
end

Validator.new.({ checked: 'false', collection: [{ checked: 'false' }] }).errors.to_h

=> {:collection=>{0=>{:checked=>["must be boolean"]}}}

Validator.new.({ checked: 'false', collection: [{ checked: 'false' }] }).to_h

=> {:checked=>false, :collection=>[{:checked=>"false"}]}

Anyone have some suggestions? :slight_smile:

You need required(:collection).array(:hash) as in the last example here https://dry-rb.org/gems/dry-schema/nested-data/

Thanks !