These are chat archives for dry-rb/chat

25th
Jul 2018
Nazar Matus
@FunkyloverOne
Jul 25 2018 13:26
Hey guys! I'm afraid this is a bit wrong place to ask, but still, I hope it won't bother you guys much. My question is about Operation objects, and how "smart" they should be in terms of input validation? Should they simply "trust" that they will get all valid, instead of having bunch of validations, almost everywhere? :D
Grant Shangreaux
@gcentauri
Jul 25 2018 15:31
are you talking about using dry-transaction?
@FunkyloverOne
Nazar Matus
@FunkyloverOne
Jul 25 2018 15:31
yes
Grant Shangreaux
@gcentauri
Jul 25 2018 15:36
well, i haven't used it yet personally, but it looks like in the first example you might have the initial operation do all your validations so you can indeed pass trusted data on to the operations that follow
Nazar Matus
@FunkyloverOne
Jul 25 2018 15:37
I guess my question would not need an answer if an Operations was just a methods inside transaction, but we have this cool feature of "operation objects" which than are going to containers, and from containers to transactions... Well it also means that you can actually use that operation anywhere else, as it is standalone reusable piece of code, right? Perhaps you kinda just should use it anywhere else, but still :)
OK, thanks @gcentauri
Grant Shangreaux
@gcentauri
Jul 25 2018 15:42
that is a good point. i probably don't have enough experience with it to really answer your question. I know that I would prefer not to have validations all over the place and instead have specific validations for specific operations. I suppose if you wanted to reuse the same operation on different data maybe you could just register a different validator to ensure the following operation gets valid data?
i guess the way i think of it is that in any series of steps, the first one will likely always be validating input data so the following steps won't break and won't have to do their own redundant validations
Nazar Matus
@FunkyloverOne
Jul 25 2018 15:43
right, I think this is most optimal solution, kinda the way it meant to be used :) thanks again @gcentauri !
Grant Shangreaux
@gcentauri
Jul 25 2018 15:44
yes, no problem. i am a fan of the dry libraries and want to continue learning about how they are intended to be used with the rest of the community!