These are chat archives for dry-rb/chat

1st
Dec 2015
@kwando ^^ :)
@AMHOL ^^
lemme know if you have some dsl ideas for that
we definitely need a way to explicitly name a group, which will be needed for messages, although this could default to concatenation of rule names within a group
eventually this will be nestable too, ie a group depending on another group etc
it should also be possible to create a group from rules that are applied to values from different levels of nesting
Piotr Solnica
@solnic
Dec 01 2015 11:57
if you think that’s crazy, I can assure you this kind of requirements exist :joy: I’ve got a ton of this stuff in my current client project
Andy Holland
@AMHOL
Dec 01 2015 12:06
@solnic I don't get what group is doing differently? Is it that it's calling an existing predicate with the values from two keys?
Group seems a bit of a strange name for that
Hannes Nevalainen
@kwando
Dec 01 2015 12:07
I not sure about the name, but the functionality :thumbsup:
Piotr Solnica
@solnic
Dec 01 2015 12:14
@AMHOL it groups rules so...
I mean I’m open to other names of course
the rule is called Rule::Group and is identified as :group because it is a…group :)
Andy Holland
@AMHOL
Dec 01 2015 12:15
Just looks like an eql predicate in the spec
Piotr Solnica
@solnic
Dec 01 2015 12:16
it accepts multiple args as input, so it’s different
we could just use rule(eql?: [:pass, :confirm]) maybe
Tim Riley
@timriley
Dec 01 2015 12:20
That one reads better to me.
Piotr Solnica
@solnic
Dec 01 2015 12:20
cool, I think I like it more
Tim Riley
@timriley
Dec 01 2015 12:26
If I saw the word “group” used in a validation schema, I’d expect it to allow a disparate set of predicates (on multiple keys, even) that would all need to pass together, or something.
Andy Holland
@AMHOL
Dec 01 2015 12:38
Yeah, rule works nicely IMO, much less confusing
Piotr Solnica
@solnic
Dec 01 2015 13:11
Class.new(Dry::Validation::Schema) do
  confirmation(:password)
end
cannot be more concise than this :joy:
Andy Holland
@AMHOL
Dec 01 2015 13:11
:)
Piotr Solnica
@solnic
Dec 01 2015 13:14
@AMHOL btw, uniqueness validation backed by a db should be very simple to achieve now
Andy Holland
@AMHOL
Dec 01 2015 13:15
Nice, guess it will still need a global connection?
Piotr Solnica
@solnic
Dec 01 2015 13:15
basically include App::Import(‘persistence.relations.users’) and def unique?(key, value); users.unique?(key => value);end
injected from container
Andy Holland
@AMHOL
Dec 01 2015 13:16
Ahh OK, so we need to make a new predicate for each unique constraint, makes sense :+1:
Piotr Solnica
@solnic
Dec 01 2015 13:17
@AMHOL well, it’s just a key rule
Andy Holland
@AMHOL
Dec 01 2015 13:17
Could probably do some hocus pocus to make a generic one, but would probably be a bad idea
Piotr Solnica
@solnic
Dec 01 2015 13:17
key(:email, &:unique?) will partially apply :email to the predicate
then value will be passed
so it’s gonna Just Work™
@AMHOL I will do the hocus pocus in rom-model for that
Andy Holland
@AMHOL
Dec 01 2015 13:18
Yeah, I was more meaning say if you wanted a constraint on users#email and then another on credential#token for example
Piotr Solnica
@solnic
Dec 01 2015 13:18
but a generic orm-agnostic/db-lib-agnostic predicate would be insane IMO
Andy Holland
@AMHOL
Dec 01 2015 13:18
Ahh, cool
Yep, v.bad idea
Nice work BTW, looking awesome
Piotr Solnica
@solnic
Dec 01 2015 13:36
@AMHOL thanks man, I’m close to cover all the use cases :)
but I’m gonna stop now, I feel confident enough that this is a good direction that more advanced stuff can be done later
Andy Holland
@AMHOL
Dec 01 2015 13:36
Cool, I wish I could see a before and after on your million line validators lol
Piotr Solnica
@solnic
Dec 01 2015 13:36
I gotta focus on rodakase and the book now
Andy Holland
@AMHOL
Dec 01 2015 13:37
You written any of the book yet?
Piotr Solnica
@solnic
Dec 01 2015 13:37
@AMHOL ain’t gonna happen, which is unfortunate, I’m leaving the project this month
Andy Holland
@AMHOL
Dec 01 2015 13:37
Ahh, that's a shame
Piotr Solnica
@solnic
Dec 01 2015 13:37
@AMHOL I’m about to start. first pages will be written on Friday
Andy Holland
@AMHOL
Dec 01 2015 13:37
Nice :)
Piotr Solnica
@solnic
Dec 01 2015 13:38
I need to come up with a rough plan first, but I have “intro” in my head so that’d be a start
I also need to figure out leanpub :)
90 stars on dry-validation btw :sparkles:
Andy Holland
@AMHOL
Dec 01 2015 13:39
:D
Piotr Solnica
@solnic
Dec 01 2015 13:40
it’s been a trending repo on github since last week, every day, I actually check it daily for whatever reason :joy:
Andy Holland
@AMHOL
Dec 01 2015 13:40
lol to see if any of your repos are there ;)
Piotr Solnica
@solnic
Dec 01 2015 13:43
that’s very likely
Andy Holland
@AMHOL
Dec 01 2015 13:49
It is cool tho