These are chat archives for dry-rb/chat

6th
Dec 2015
Piotr Solnica
@solnic
Dec 06 2015 16:39
Does size? predicate need a special msg when it is applied to a string? Ie size vs length?
@AMHOL @timriley ^^
Andy Holland
@AMHOL
Dec 06 2015 16:41
Hmm, yeah i think that would make sense
Piotr Solnica
@solnic
Dec 06 2015 16:46
Then I gotta extend msg lookup with one more path. It is doable. Should be useful in general anyway
Tim Riley
@timriley
Dec 06 2015 21:38
Yeah, I’d say that a string size validation is common enough (and different enough to numbers or other sorts of sets) that it’d warrant a special message.
Piotr Solnica
@solnic
Dec 06 2015 21:42
@timriley technically speaking it’s using the same predicate, but we can match on input type and provide special msg
Tim Riley
@timriley
Dec 06 2015 21:42
Makes sense.
Piotr Solnica
@solnic
Dec 06 2015 21:49
@timriley I’m also wondering if we want to have min_size / max_size when size?(range) can do the trick
Tim Riley
@timriley
Dec 06 2015 21:49
How would you handle a min size only using size?(range)? – put some arbitrary large number on the upper end?
Piotr Solnica
@solnic
Dec 06 2015 21:50
@timriley define n as infinity, like we had in DataMapper :)
Tim Riley
@timriley
Dec 06 2015 21:50
ah yeah. That works, and is still pretty clear.
Piotr Solnica
@solnic
Dec 06 2015 21:51
personally I’d prefer to type value.size?(1..100) than value.gt?(0) & value.lt?(100)
not to mention range should be faster ;)
Tim Riley
@timriley
Dec 06 2015 21:52
Yeah, it’s shorter and clearer in all cases. Haha, yes.
Piotr Solnica
@solnic
Dec 06 2015 21:52
speaking about dry-validation, wdyt about using it for validation request params, always. including GET stuff
Tim Riley
@timriley
Dec 06 2015 21:53
oooh
Piotr Solnica
@solnic
Dec 06 2015 21:53
I think I’d like to have params validation all the time, tbh, esp when I use params for db queries...
not to mention you’d have a nice way of providing good responses when request is malformed
rather than OOPS 500 ZOMG :)
Tim Riley
@timriley
Dec 06 2015 21:54
so this’d kind of be like a more-powerful kind of alternative to Rails’ strong params?
Piotr Solnica
@solnic
Dec 06 2015 21:54
of course
Tim Riley
@timriley
Dec 06 2015 21:54
Used in the same kind of way, I mean: right in the web request.
Piotr Solnica
@solnic
Dec 06 2015 21:55
from your app pov, it’s just validating the arguments that are used to call a given endpoint
Tim Riley
@timriley
Dec 06 2015 21:55
I think that makes sense, especially if we can find a way for them to be integrated at that point without too much boilerplate.
Yeah.
Piotr Solnica
@solnic
Dec 06 2015 21:55
I think this can be very slick with the DSL we have
Tim Riley
@timriley
Dec 06 2015 21:55
It can mean less defensive work in the rest of your apps’ operation objects, too.
Piotr Solnica
@solnic
Dec 06 2015 21:55
totally
not to mention automatic coercions
Tim Riley
@timriley
Dec 06 2015 21:55
:)
Coerce at the boundary, rather than deeper in your code.
Piotr Solnica
@solnic
Dec 06 2015 21:56
yeah
Tim Riley
@timriley
Dec 06 2015 21:56
Otherwise you’re carrying HTTP baggage further than you need to.
Piotr Solnica
@solnic
Dec 06 2015 21:56
exactly
and hello accidental complexity
Tim Riley
@timriley
Dec 06 2015 21:56
Yep.
Piotr Solnica
@solnic
Dec 06 2015 21:57
HTTP-related nonsense leaking into your app
Tim Riley
@timriley
Dec 06 2015 21:58
Seems thoroughly obvious to me that it should be done this way, now.
Piotr Solnica
@solnic
Dec 06 2015 21:59
yep, maybe we could have a roda plugin for that provided by rodakase or something
Tim Riley
@timriley
Dec 06 2015 21:59
I think that makes sense.
Piotr Solnica
@solnic
Dec 06 2015 22:00
I’ve been benchmarking dry-v and so far it’s ridiculously fast, so this should not have a bad impact on the performance, esp that you want coercions anyway
Tim Riley
@timriley
Dec 06 2015 22:01
Yeah, they’ll happen at some point.