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)
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?