These are chat archives for dry-rb/chat

27th
Sep 2017
MarkT
@paradisaeidae
Sep 27 2017 05:43
Hi, I think my Dry gems have got out of sync: Gem::ConflictError: Unable to activate rom-sql-1.3.4, because dry-types-0.12.0 conflicts with dry-types (~> 0.10.2)
I've culled a few of the versions. Is there a back-version compatibility I've toasted?
Tim Riley
@timriley
Sep 27 2017 06:27
Have you specified an 0.12 version of dry-types somewhere in your own gemfile?
Piotr Solnica
@solnic
Sep 27 2017 10:13
@paradisaeidae pin dry-types to ~> 0.11.0
latest dry-types includes changes that were required for rom-sql 2.0.0
Aaron Jensen
@aaronjensen
Sep 27 2017 22:24
Hi all, if I define a struct w/ dry-struct, and attempt to instantiate one w/ invalid data, it looks like it throws, is that right? Is there a non-throwing way of doing validation? Like some sort of collaboration w/ dry-monad?
or should I be looking at dry-validation first
Tim Riley
@timriley
Sep 27 2017 23:26
@aaronjensen I think your hunch to look at dry-validation is right :)
that’s its job — accepting and validating input data and allowing action to be taken based on a valid/invalid result
whereas structs are meant to be strict — they expect valid data from the beginning, and if they don’t receive it, this should be treated as a programmer error, hence the exception raising behaviour
Aaron Jensen
@aaronjensen
Sep 27 2017 23:46
it looks like structs may have a try method?
that's often what I want... give me a struct if it's valid, otherwise let me do something else /cc @timriley. It prevents me from having to duplicate the schema
Tim Riley
@timriley
Sep 27 2017 23:47
@aaronjensen In the future we’re hoping we can add some convenience for having dry-v schemas derived from struct definitions, but right now, you’d want the both.
But I think it’s an appropriate separation of responsibilities.
Aaron Jensen
@aaronjensen
Sep 27 2017 23:47
not very dry tho ;)
Tim Riley
@timriley
Sep 27 2017 23:48
Well, it’s not uncommon that you want to do slightly different things at the validation stage compared to the struct-building stage.
Aaron Jensen
@aaronjensen
Sep 27 2017 23:48
yeah, i'm thinking about form objects. which, tbh, I don't understand how they work w/o this
Tim Riley
@timriley
Sep 27 2017 23:49
without what, sorry?
so with CreateForm, for example.. if I new that up with no address, it'd throw, right?
Tim Riley
@timriley
Sep 27 2017 23:52
if you add constructor_type :schema to the class definition, it won’t raise
See A note about the dry-types struct constructor in that article
Aaron Jensen
@aaronjensen
Sep 27 2017 23:53
ah, i see.
so, similar to AM/AR, attributes defined in one place, valdiations defined in another, just in this the other is a different class..
ok, that is helpful, thank you.
Tim Riley
@timriley
Sep 27 2017 23:54
Yeah.
Cool :)
Aaron Jensen
@aaronjensen
Sep 27 2017 23:54
btw, i'm back to the ruby community after a few years... what's the status of ROM now a days
Tim Riley
@timriley
Sep 27 2017 23:54
It’s (almost) at version 4.0 and it’s rocking hard
Aaron Jensen
@aaronjensen
Sep 27 2017 23:55
it looks like it's closer to ecto than AR
is that right?
Tim Riley
@timriley
Sep 27 2017 23:55
Yeah, that’d be right.
Aaron Jensen
@aaronjensen
Sep 27 2017 23:56
interesting.
ok, i'll have to take a look. we're just getting started on a project and have some AR stuff already... but I'm more of a fan of ecto's model
how close is 4.0 and is it a big change?
Tim Riley
@timriley
Sep 27 2017 23:58
4.0 is practically out the door, release is just pending some final work on docs. You should definitely use it.