These are chat archives for dry-rb/chat

23rd
May 2016
Tim Riley
@timriley
May 23 2016 00:37 UTC
Made dry-component’s injector support a little more flexible: dry-rb/dry-component#12
With that in place I think we can probably push out a few releases this week
Piotr Solnica
@solnic
May 23 2016 09:04 UTC
@timriley oh wow!
you are really pushing this forward man, kudos! :heart_eyes:
Tim Riley
@timriley
May 23 2016 09:58 UTC
@solnic thanks! :)
Ralf Schmitz Bongiolo
@mrbongiolo
May 23 2016 14:44 UTC
Can type? on dry-validation be used to coerce values? Or should I do custom coercions before/after?
This: optional(:device_id).filled(type?: Miss::Types::Strict::Int) is giving an error => optional(:device_id).filled(type?: Miss::Types::Strict::Int), is it really an error or am I using :type? in the wrong way?
Ralf Schmitz Bongiolo
@mrbongiolo
May 23 2016 14:50 UTC
Correct error message: Nothing registered with the key "#" (Dry::Container::Error)
I'm using dry-v master.
That should be -10 by now :p lol
Ralf Schmitz Bongiolo
@mrbongiolo
May 23 2016 17:25 UTC
KInd of solved it, had to use it like this:
optional(:cellphone).filled(Miss::Types::Phone,
  :valid_phone?,
  unique?: [::Customer, :cellphone])
Luca Guidi
@jodosha
May 23 2016 17:27 UTC
@AMHOL OMG, that article is just embarassing.
Ralf Schmitz Bongiolo
@mrbongiolo
May 23 2016 17:27 UTC
Is there a way to make dry-validation return the correct error if a type like this is not correct? If I try to use a "stricter" version it will raise an error, instead of just adding an error messaged like: cellphone: ["the given type is not correct"].
Andy Holland
@AMHOL
May 23 2016 17:27 UTC
Yeah, I love the last paragraph too lol
Luca Guidi
@jodosha
May 23 2016 17:28 UTC
@AMHOL Read my comment ;)
James Hamilton
@wjdhamilton
May 23 2016 17:28 UTC
@AMHOL it really sounds like he's trying very hard to rationalise why he shouldn't listen to those who disagree with him
Andy Holland
@AMHOL
May 23 2016 17:29 UTC
@mrbongiolo I think that's because you're using Strict types, not 100% sure but I think Coercible types have the behaviour you want
@jodosha I wasn't aware it added that many methods, the problem is worse than I thought
@wjdhamilton Rails uses those sharp knives to create a lot of short cuts <3
James Hamilton
@wjdhamilton
May 23 2016 17:33 UTC
:smile:
Piotr Solnica
@solnic
May 23 2016 17:35 UTC
No matter what arguments DHH is using, what he’s saying always boils down to “shut up, I like my basecamp”
Andy Holland
@AMHOL
May 23 2016 17:38 UTC
From that article tho, the part about If that’s your position, Ruby is probably not for you. really pisses me off
If he said Rails, no problem, but he didn't
Piotr Solnica
@solnic
May 23 2016 17:40 UTC
I’ll try to comment
Ralf Schmitz Bongiolo
@mrbongiolo
May 23 2016 18:07 UTC
@AMHOL I was trying to use coercible, but couldn't get them to work also, will try again here

when I try to use this:

Phone = Dry::Types['coercible.string'].constructor { |input|
      Miss::Phony.normalize(input)
    }

it fails with => 'method_missing': undefined methodto_ast' for #<Dry::Types::Constructor:0x005630daff84b0> (NoMethodError)`
I'm probably doing something a bit different of what it should be done, just couldn't figure it out what's going on

Well, for now I got it working with a "non" strict version that just return the original input if it's not a valid phone, then I use a custom predicate to check if the input is a valid phone number or not. But I thought this could be done in one step with a custom type...
Andy Holland
@AMHOL
May 23 2016 18:17 UTC
@mrbongiolo sorry I haven't used dry-types extensively enough to know what the problem is there without debugging
Ralf Schmitz Bongiolo
@mrbongiolo
May 23 2016 18:18 UTC
It's fine, I'll keep on digging, this is more dry-validation related really, since I'm trying to use a custom type with it
maybe it isn't supposed to work the way I thought it would :D
Piotr Solnica
@solnic
May 23 2016 18:27 UTC
@mrbongiolo only constrained types are supported
we need to improve this integration
I plan to add an explicit type(something) interface to the DSL
this deserves to be separated
Ralf Schmitz Bongiolo
@mrbongiolo
May 23 2016 18:35 UTC
@solnic Ok, thanks for the info. Would it be wrong for dry-validation to already coerce values when using a coercible type?
Piotr Solnica
@solnic
May 23 2016 18:37 UTC
@mrbongiolo it is doing that, the problem is that it must be wrapped by a constrained type, there are ways to achieve that but I don’t have time atm to show it to you
Ralf Schmitz Bongiolo
@mrbongiolo
May 23 2016 18:38 UTC
I'll look into the constrained types then and see if I can do it :D
Pablo Herrero
@pabloh
May 23 2016 20:43 UTC
Hello, can anyone point me to a fairly big or at least non trivial example of a Roda based REST API?
Artur Dębski
@mentero
May 23 2016 23:44 UTC
Hi. I am looking into gems in dry-rb and I am trying to figure out what is the actual difference between dry-constructor and dry-initializer. They both seem to tackle similar problem. Is there any possible reason to chose dry-constructor instead of dry-initializer?
Tim Riley
@timriley
May 23 2016 23:45 UTC
I think we’re going to retire dry-constructor, @mentero
So I think you could happily discount that from your investigations
Artur Dębski
@mentero
May 23 2016 23:46 UTC
cool
thanks a lot