These are chat archives for dry-rb/chat

27th
Jan 2016
Piotr Solnica
@solnic
Jan 27 2016 11:30
Randomized with seed 65498
...............................................................................................................................

Finished in 0.1832 seconds (files took 0.18669 seconds to load)
127 examples, 0 failures
:tada: :tada: :tada: :tada: :tada: :tada: :tada: :tada: :tada: :tada:
Tim Riley
@timriley
Jan 27 2016 11:30
wow, you did it!
Let’s retire that seed number.
Luca Guidi
@jodosha
Jan 27 2016 11:31
@timriley :joy_cat:
Piotr Solnica
@solnic
Jan 27 2016 11:34
@timriley well, the current specs are passing (with a couple of new ones), but I still have some scenarios to cover :)
Piotr Solnica
@solnic
Jan 27 2016 11:40
because here’s what I actually want to support, too:
class Foo < Dry::Validation::Schema
  key(:foo).required(:hash?) do |foo|
    foo.key(:bar).required
  end

  key(:baz).maybe

  rule(:baz_when_bar) do
    value(:foo).value(:bar).eql?('1').then(value(:baz).eql?('1'))
  end
end
which means being able to define rules that rely on values coming from deeply nested structures
Tim Riley
@timriley
Jan 27 2016 11:43
ah, that would be super cool
Piotr Solnica
@solnic
Jan 27 2016 11:43
it’s yet another personal pet peeves of mine
Tim Riley
@timriley
Jan 27 2016 11:44
What’s that?
Piotr Solnica
@solnic
Jan 27 2016 11:45
being able to easily specify rules that depend on various values that are in “distant” places from each other
it’s always such a PITA when you use AM
tons of nil checks, type checks, nasty conditionals etc
Tim Riley
@timriley
Jan 27 2016 11:45
Yeah

Heh. I think I’m in need of your nice macros right now – writing a schema for an “update your account” form where the password is allowed to be blank if you don’t want to change it.

I’ll do it the old way though :wink2:

Piotr Solnica
@solnic
Jan 27 2016 11:48
@timriley build is green, I could merge into master and you could grab it
but it needs dry-logic from master too
Tim Riley
@timriley
Jan 27 2016 11:49
Thanks for the offer, but it’s cool, take the time you need :)
Piotr Solnica
@solnic
Jan 27 2016 11:49
I’d appreciate if you could try it out actually :)
Tim Riley
@timriley
Jan 27 2016 11:50
Ok, sure thing!
I might do that part in the morning.
It’s getting close to :zzz: time.
Piotr Solnica
@solnic
Jan 27 2016 11:50
ok, good night then :)
Piotr Solnica
@solnic
Jan 27 2016 13:44
Class.new(Schema) do
  key(:email).maybe

  key(:settings) do |settings|
    settings.key(:newsletter).required(:bool?).when(:true?) do
      value(:email).filled?
    end
  end
end
^^ this now works
363 LOC is gone :dancers:
Piotr Solnica
@solnic
Jan 27 2016 14:22
@fran-worley @jodosha @mrbongiolo macros with a bunch of improvements are in master…please test it out :)
@fran-worley it should work with reform now
Fran Worley
@fran-worley
Jan 27 2016 14:23
@solnic looks great I'll give it a go!
Piotr Solnica
@solnic
Jan 27 2016 14:32
fyi the build errored due to some issues with gh
it’s all green
Piotr Solnica
@solnic
Jan 27 2016 15:21
there are still a couple of cases to cover when it comes to nested data and high-lvl rules, but it’s not gonna be hard
Luca Guidi
@jodosha
Jan 27 2016 17:17
@solnic :heart: I can't right now :( Preparing a meeting for a new customer
Piotr Solnica
@solnic
Jan 27 2016 17:27
@jodosha no rush at all! :)