Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Piotr Solnica
@solnic
we could start at least chatting about it :)
cheers
:wave:
Andy Holland
@AMHOL
Yeah, just give me a shout when you do
Piotr Solnica
@solnic
will do
Andy Holland
@AMHOL
@solnic you around?
Piotr Solnica
@solnic
Kinda
Andy Holland
@AMHOL
lol, just messing about with the validator stuff
Piotr Solnica
@solnic
Oh cool. Where?
Andy Holland
@AMHOL
Not pushed it anywhere yet, just making a gist
The gist vs the comment
I'm leaning towards the gist myself, that would allow the processor to be switched out for nested validations or anything else someone wants to do
Then I can put the extractor/validation container config on the processor
WDYT?
Piotr Solnica
@solnic
I'll check it out tomorrow. Too late for me already :)
Andy Holland
@AMHOL
:+1: cheers
Andy Holland
@AMHOL
Getting somewhere with this now
Andy Holland
@AMHOL
v = Dry::Validator.new(
  name: {
    presence: true
  },
  test: {
    embedded: {
      tester: {
        presence: true
      }
    }
  }
)

v.call(name: '', test: { tester: '' })
# => {:name=>[{:code=>"presence", :options=>true}], :test=>[{:tester=>[{:code=>"presence", :options=>true}]}]}
v.call(name: 'Joe', test: { tester: 't' })
# => {}
v = Dry::Validator.new(
  users: {
    each: {
      name: {
        presence: true
      }
    }
  }
)

v.call(users: [{ name: 'Joe' }, { name: '' }])
# => {:users=>[{}, {:name=>[{:code=>"presence", :options=>true}]}]}
v.call(users: [{ name: 'Joe' }])
# => {}
Piotr Solnica
@solnic
looking good
Andy Holland
@AMHOL
:)
Piotr Solnica
@solnic
btw I really like Dry name
because Dry has been misunderstood by many rubyists and not everybody realized what it really means
Andy Holland
@AMHOL
Yeah, I've seen a few cases of that too lol
Piotr Solnica
@solnic
FWIW DRY in Rails mostly means “I’m gonna use reflection and make millions of assumptions so that you will just inherit from this magic class and more magic will appear"
:sparkles:
Andy Holland
@AMHOL
haha yeah
AR DRY
Was wondering whether this was going to turn into a framework last night lol
I think that developing these small libraries with small concerns makes for better code
Piotr Solnica
@solnic
small libs are fantastic except one thing
it’s called dependency hell :)
it’s the reason why I don’t like to start with small libs and prefer extractions
and I am very very careful about deciding when it’s good to extract
extracting unstable code will always mean much more work
we’ve been there with DM2 that’s how I’ve learned it, the hard way™
Andy Holland
@AMHOL
You could have told me this earlier :joy:
Piotr Solnica
@solnic
haha nah man, those things in Dry has been done in one form or another so many times we’re in a good position to build them up from scratch in isolation
I’m talking about things like building a biggerish thing like ROM via bottom-up approach, that part didn’t work at all for DM2
hey so
this part, I’m not sure if it’s a good idea to try both [] and a reader
seems too ambiguous to me
Andy Holland
@AMHOL
Yeah, it was just that I wanted it to be able to validate an object or a hash without configuration, but I did think that it was a bit of a smell myself
Piotr Solnica
@solnic
probably sticking to [] would be best, but that’s just my initial gut feeling
yeah right?
truth is 99% of the libs with data-objects provide both [] AND readers
Andy Holland
@AMHOL
Ahh OK
Piotr Solnica
@solnic
AR, all ORMS, Virtus, Anima, all 3124 Virtus clones etc.