These are chat archives for dry-rb/chat

Jan 2019
Manic Chuang
Jan 10 01:50

Hi guys, it seems that I maybe encounter a bug of dry-types SUM, but I'm not sure. Could you help me on this?

It happens when I try to verify a object which should be a hash or a string

test = Dry::Types['hash'].map(Dry::Types['symbol'], Dry::Types['strict.string']) | Dry::Types['strict.string']
test[a: 'b'] # passed as expected
test['a' => 'b'] # should fail but pass!
test['test'] # passed as expected
test[12345] # should fail but pass!

I'm wondering if there is anything that I didn't notice or I use the wrong way to build my rule. Thanks :)

Tim Riley
Jan 10 04:36
@manic I tried this, using “strict.symbol” instead of “symbol” (which IMO you probably want) and it still fails in the way you’re seeing. Could you please file a bug?
Manic Chuang
Jan 10 06:26
@Tim Sure, thank you
Manic Chuang
Jan 10 07:02
@timriley dry-rb/dry-types#280 here it is.
Pablo Crivella
Jan 10 12:47
Any idea how could i make this Map type also accept nil as values?
Links = Map(Symbol, String | JSONAPI::Types::Link)
This works but i’m not sure if its the correct way:
Links = Map(Symbol, String | JSONAPI::Types::Link.optional)
Nikita Shilnikov
Jan 10 12:53
no idea, probably related to the issue above