These are chat archives for dry-rb/chat

7th
Jan 2016
Tim Riley
@timriley
Jan 07 2016 06:54
I have to say, the dry-v AST stuff has been such an inspiration for me, thanks @solnic!
It’s let me defer the evaluation of a DSL-defined element tree until a time when I have all the information that I need. And using a visitor-pattern compiler means I don’t need to pass supporting objects all the way through the tree.
Piotr Solnica
@solnic
Jan 07 2016 06:55
exactly
:D
this is a really nice abstraction and it’s a pretty simple pattern
btw I learned this stuff from mbj and his work on morpher
but he used a more sophisticated ast processing pattern (using ast gem + his own machinery)
Hannes Nevalainen
@kwando
Jan 07 2016 10:57
is there a way of having optional keys in dry-validation?
sorry, couldn’t help myself :joy:
Hannes Nevalainen
@kwando
Jan 07 2016 10:59
lol, I was just reading the wiki =P
Piotr Solnica
@solnic
Jan 07 2016 11:04
do not confuse optional key with optional value
two different things in dry-v world
Tim Riley
@timriley
Jan 07 2016 11:33
  spec.add_runtime_dependency "dry-configurable"
  spec.add_runtime_dependency "dry-container"
  spec.add_runtime_dependency "dry-data", ">= 0.4.2"
  spec.add_runtime_dependency "dry-validation"
  spec.add_runtime_dependency "inflecto"
These gems are so helpful :D
Piotr Solnica
@solnic
Jan 07 2016 11:33
:sparkles: :sparkles: :sparkles: :sparkles: :sparkles:
Tim Riley
@timriley
Jan 07 2016 11:33
-configurable, -container and -v all got added in the last 2 days
so easy to work with
Piotr Solnica
@solnic
Jan 07 2016 11:34
that’s great to know
I’ll be doing some work on d and v next week
I want to push dry-d a bit and make it more robust in terms of error handling
Tim Riley
@timriley
Jan 07 2016 11:34
working with the dry-v #messages structure was a little bit hairy, but I think it was just a matter of figuring it out.
Piotr Solnica
@solnic
Jan 07 2016 11:34
and simplify the API too
adding types should be trivial
Tim Riley
@timriley
Jan 07 2016 11:35
It’s great it has all the data present, though, and not just stringy messages only – that was critical.
Piotr Solnica
@solnic
Jan 07 2016 11:35
@timriley messages format is unsettled
Tim Riley
@timriley
Jan 07 2016 11:35
Heh. Good to know. I’ll keep an eye on it then.
Piotr Solnica
@solnic
Jan 07 2016 11:35
we need more testing and feedback to come up with a structure that’s easy to work with
maybe we need heavier representation with objects coercible to strings
^ some of my dry-v messages munging
Piotr Solnica
@solnic
Jan 07 2016 11:36
yeah exactly
:joy:
things get hairy when you’re dealing with nested errors, esp with arrays
Tim Riley
@timriley
Jan 07 2016 11:36
I’m going to box that all up in an errors interrogator class, anyway
to centralise it, keep it tidy
Piotr Solnica
@solnic
Jan 07 2016 11:37
possible that this would become a great starting point to introduce improvements in dry-v
Piotr Solnica
@solnic
Jan 07 2016 11:42
@timriley so, how do you use formalist ast?
Piotr Solnica
@solnic
Jan 07 2016 11:43
a-ha!
Tim Riley
@timriley
Jan 07 2016 11:43
The idea is that we can support multiple rendering backends. This is what we’ll use in most places, though.
I think at some point I’ll add a standard server-renered HTML backend, maybe.
Piotr Solnica
@solnic
Jan 07 2016 11:43
that would be awesome
Tim Riley
@timriley
Jan 07 2016 11:43
I have a GIF from a while ago
It’s only a snippet, but it shows that we hope to be able to build super nice forms.
Piotr Solnica
@solnic
Jan 07 2016 11:44
that’s so exciting!
Tim Riley
@timriley
Jan 07 2016 11:45
And we even have it so you can replace certain field components on a form-by-form basis
Piotr Solnica
@solnic
Jan 07 2016 11:45
we’re taking things to the next level :dancers:
Tim Riley
@timriley
Jan 07 2016 11:45
So you’re never stuck with a standard form component if you need something custom.
And yeah, this whole thing is persistence-agnostic.
Focus on making the best form first, then pass data in, get data out.
Up to you what you do with it.
Will need to work out some conveniences to make the data in/out somewhat nice for common cases though, I think.
Piotr Solnica
@solnic
Jan 07 2016 11:47
sure thing
Tim Riley
@timriley
Jan 07 2016 11:47
:)
Piotr Solnica
@solnic
Jan 07 2016 11:47
so, lemme get this straight - you’re translating validation ast into a form ast which is then compiled into a react component which can render a form and provide error messages?
Tim Riley
@timriley
Jan 07 2016 11:48
Yep.
Piotr Solnica
@solnic
Jan 07 2016 11:48
holy moly that is awesome
Tim Riley
@timriley
Jan 07 2016 11:48
Was a crazy idea that’s looking like it might just work out :)
Piotr Solnica
@solnic
Jan 07 2016 11:49
so I’ve got an immediate proof that this whole ast-based approach wasn’t YAGNI at all (I knew it wasn’t but others can think like that)
Tim Riley
@timriley
Jan 07 2016 11:49
Yep. Validation integration would have been extremely difficult without dry-v.
Piotr Solnica
@solnic
Jan 07 2016 11:49
that was one of the reasons why I wanted an abstract representation of validation rules in the first place
Tim Riley
@timriley
Jan 07 2016 11:49
I plan to integrate the rules too, btw, not just the messages.
That way the form can show hints and also do matching client-side validations.
Piotr Solnica
@solnic
Jan 07 2016 11:50
that would be mind blowing
I hope to see it one day :)
Tim Riley
@timriley
Jan 07 2016 11:50
You most certainly will.
Piotr Solnica
@solnic
Jan 07 2016 11:54
we so gotta blog about this stuff man
Tim Riley
@timriley
Jan 07 2016 11:54
I know! :weary:
Piotr Solnica
@solnic
Jan 07 2016 11:54
(at some point)
:D
Kareem Hepburn
@magicalbanana
Jan 07 2016 18:05
What's the logic behind not adding conditionals to the validations?
Piotr Solnica
@solnic
Jan 07 2016 18:16
@magicalbanana wdym?
Kareem Hepburn
@magicalbanana
Jan 07 2016 18:16
Why are conditionals not a standard feature for this validation library. What's the reasoning behind it?
Piotr Solnica
@solnic
Jan 07 2016 18:17
they are not needed, you can express everything through predicate logic, which actually has conditional logic, it’s just expressed in a different way
Kareem Hepburn
@magicalbanana
Jan 07 2016 18:18
Ah I see. That's good to know! I made a little validation library too but I kept the conditionals.
Piotr Solnica
@solnic
Jan 07 2016 18:18
I dislike validation DSL with options a lot, I think it’s simpler to understand validation logic when it’s…logical :)
fwiw we could have a DSL on top of predicates but it wouldn’t be as flexible as what we have already so I don’t see any point in doing that
I understand that people are used to typical validation DSLs but I’d like to try something else instead
Kareem Hepburn
@magicalbanana
Jan 07 2016 18:20
That's true. But eh, it was my first validation library. :D I wanted to have a more domain driven approach on things where my entities' validation if any are of a separate concern.
Piotr Solnica
@solnic
Jan 07 2016 18:20
dry-validation is for validating data at the boundaries of your system, far far away from “domain entities"
there is a feature planned for validating “models” but I don’t see much use cases for that
Kareem Hepburn
@magicalbanana
Jan 07 2016 18:21
My validator PoroValidator is a WIP still but if you have some spare time @solnic I'd be delighted for some inputs.
The core classes are done just need to add some base validations. :)
Piotr Solnica
@solnic
Jan 07 2016 18:23
I’m recently against the idea of validating objects and I’m drawing a line between input coming from the outside and objects that you could instantiate from that input
Kareem Hepburn
@magicalbanana
Jan 07 2016 18:26
Hmm. I would like to hear your thoughts as to why you're recently against idea of validating objects.
that’s in brief, it’s a big subject, I’ll try to write a follow-up post soon
Kareem Hepburn
@magicalbanana
Jan 07 2016 18:41
Ah, thanks man!
Piotr Solnica
@solnic
Jan 07 2016 18:43
I found it hard to discuss because most people look at it from AR’s pov
Kareem Hepburn
@magicalbanana
Jan 07 2016 18:58
Yeah, I do like the validation on the boundary level.
Piotr Solnica
@solnic
Jan 07 2016 19:12
it’s the only thing that makes sense, really