These are chat archives for dry-rb/chat

30th
Nov 2018
Ahmad Musaffa
@musaffa
Nov 30 2018 00:01
The example shows deploying a Sinatra app in AWS Lambda. Deploying dry-web-rodaapp should also be trivial.
Grant Shangreaux
@gcentauri
Nov 30 2018 04:38
Hoping to get something at my work using dry/rom/lambda . There was
Piotr Solnica
@solnic
Nov 30 2018 11:51
this is awesome news indeed :)
Nikita Shilnikov
@flash-gordon
Nov 30 2018 11:52
AFAIK cobol is also supported
Jeff Dickey
@jdickey
Nov 30 2018 14:30
Coming soon: IBM RPG :older_man:
not to take away from the awesomeness; anything that lets devs use their favourite/existing-products' languages in new ways is almost by definition a Good Thing
Christian Georgii
@cgeorgii
Nov 30 2018 15:54

Hi, I've been thinking about opening a pull request for dry-struct to make it quack a bit more like a hash in order to enable validating it with dry-validation. Nowadays an attempt to call a schema with a struct object throws an error. I don't understand if this is a conscious design decision because it seems like a useful use case.

What I want to enable is this:

schema = Dry::Validation.Schema { required(:age).filled(gteq?: 18) }

User.new(age: 17)

schema.(user)
#<Dry::Validation::Result output=#<User age=17> errors={:age=>["must be greater than or equal to 18"]}>
Nikita Shilnikov
@flash-gordon
Nov 30 2018 15:55
you're supposed to create structs from valid data hence it doesn't make sense to pass structs to dry-v
Christian Georgii
@cgeorgii
Nov 30 2018 15:59
Ok, thanks for the quick answer

Another question, then

BMI = Dry::Types['strict.int'].constrained(gteq: 18, lteq: 42).constructor { |x| x.round }

BMI[17.5]
#=> 18

BMI.valid?(17.5)
#=> false

Does this behavior make sense or is it a bug?

Nikita Shilnikov
@flash-gordon
Nov 30 2018 16:04
not something I would expect tbh
mb there are reasons for that, requires checking out the code
Christian Georgii
@cgeorgii
Nov 30 2018 16:05
Ok, I will take a look
Nikita Shilnikov
@flash-gordon
Nov 30 2018 16:07
@solnic https://github.com/dry-rb/dry-types/blob/287e732d12a96ab9f54955754f10d4afa5e5abf8/lib/dry/types/constructor.rb#L82 here the constructor types doesn't apply fn to value. Doesn't it seem wrong?
@cgeorgii ^
Piotr Solnica
@solnic
Nov 30 2018 16:12
@flash-gordon it does
Nikita Shilnikov
@flash-gordon
Nov 30 2018 16:13
@cgeorgii pls file an issue, I'll take care of it tomorrow
Christian Georgii
@cgeorgii
Nov 30 2018 16:14
Alright, but let me know if you want me to take a stab at it ;)
Nikita Shilnikov
@flash-gordon
Nov 30 2018 16:14
permission granted ;)
Christian Georgii
@cgeorgii
Nov 30 2018 16:15
Cool, I will let you know