These are chat archives for dry-rb/chat

10th
Jan 2019
Manic Chuang
@manic
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
@timriley
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
@manic
Jan 10 06:26
@Tim Sure, thank you
Manic Chuang
@manic
Jan 10 07:02
@timriley dry-rb/dry-types#280 here it is.
Pablo Crivella
@pablocrivella
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
@flash-gordon
Jan 10 12:53
no idea, probably related to the issue above