These are chat archives for dry-rb/chat

7th
Mar 2016
Hannes Nevalainen
@kwando
Mar 07 2016 07:21
@solnic
module Validator
  def self.build(&block) do
    MyValidatorWrapper.new(Class.new(Dry::Validation::Schema){ instance_exec(&block)  }.new)
  end
end
Piotr Solnica
@solnic
Mar 07 2016 14:45
@kwando ah of course, thanks
I’m thinking about something like Dry::Validation.Schema do … end
that would accept args and options
so for inheritence Dry::Validation.Schema(other_schema) do .. end
for coercion Dry::Validation.Schema(coercion: :form) do .. end
and so on
Hannes Nevalainen
@kwando
Mar 07 2016 14:50
cool stuff!
Piotr Solnica
@solnic
Mar 07 2016 14:50
yeah, it’s gonna simplify implementation too
Hannes Nevalainen
@kwando
Mar 07 2016 14:50
Can you specify your own types in a schema yet?
Piotr Solnica
@solnic
Mar 07 2016 14:50
class-level DSLs are so horrible to implement
@kwando no :( I will try to implement that for 0.7.0
it’s not a big deal tbh but my time constraints are brutal
and I REALLY need to go back to ROM :)
oh btw I forgot to mention this here - dry-types refactor is done so new stuff is in master, I’ve got a couple of issues to address and then I’ll push first release of dry-types (it’s gonna be 0.6.0 because prev ver of dry-data was 0.5.x)
so we’re getting really close to a major upgrade of dry-v+t+l :)
Hannes Nevalainen
@kwando
Mar 07 2016 14:59
Don't worry, I'm working around it atm =)
Piotr Solnica
@solnic
Mar 07 2016 15:00
btw default value types will be supported in the upcoming release
ie key(:status, Types::Posts::Status)
where this type could be ie Status = String.default(‘draft’)
or some enum, whatever
this is actually a general feature where you can pass a dry type to key
and it’s gonna extract rules from it
ie Strict::String == str?
or Strict::String.constrained(size: 3..10) == str? & size?(3..10)
Hannes Nevalainen
@kwando
Mar 07 2016 15:03
Oh, that looks lovely! =)
Piotr Solnica
@solnic
Mar 07 2016 15:03
this is gonna be an important feature as you’ll be able to share very important info across multiple places very very easily
types are super lightweight, so it’s easy to share them
ie same type can be used for defining a db schema, then in a model definition and then in a schema, too
it’s gonna completely remove duplication of knowledge
and you know, it’s gonna be DRY :joy:
Hannes Nevalainen
@kwando
Mar 07 2016 15:05
I'll have to meditate on all that, you are way ahead as usual =P
Piotr Solnica
@solnic
Mar 07 2016 15:05
hah :) you do that and lemme know your thoughts :)
Hannes Nevalainen
@kwando
Mar 07 2016 15:06
The only thing that is not dry now is my Gemfile, dy-data, dry-validation, dry-equalizer, dry-container, dry-auto_inject :joy:
Piotr Solnica
@solnic
Mar 07 2016 15:07
%w(data validation equalizer container auto_inject).each { |n| gem “dry-#{n}” } :joy:
Hannes Nevalainen
@kwando
Mar 07 2016 15:08
yeah, but no. Not gonna happen =P
Piotr Solnica
@solnic
Mar 07 2016 15:08
fair enough ;)
Hannes Nevalainen
@kwando
Mar 07 2016 15:09
I've been spending some quality time with dry-component, I like it a lot =)
Piotr Solnica
@solnic
Mar 07 2016 15:09
oh yeah? that’s great news
lots of rough edges there though, we’ve got a long backlog with @timriley but we’ll get to it sooner or later :)
Hannes Nevalainen
@kwando
Mar 07 2016 15:11
yeah, there are a few things I'm not that fond of but nothing major
Piotr Solnica
@solnic
Mar 07 2016 15:11
remember to report issues
although I’m pretty sure we’ve stumbled upon same/similar issues hah
after validation/types are released, I need to finish schema support for rom-sql and command support for rom-repository, after that’s done I’ll get back to rodakase/dry-component
I actually want to extract dry-view from rodakase and add dry-web for building web app stacks and turn rodakase into a dry-web stack using roda for the routing part
oh and there are some major improvements coming to dry-auto_inject
we gotta finish dry-constructor and use it in auto_inject
Hannes Nevalainen
@kwando
Mar 07 2016 15:15
feels like X-mas all over again =P
Piotr Solnica
@solnic
Mar 07 2016 15:15
there will be support for different types of constructors (positioned args, hash and k/v args) and support for aliasing
oh and support for inheritance, as that doesn’t work at all right now (as in, it’s not implemented)
Hannes Nevalainen
@kwando
Mar 07 2016 15:50
ARGH! how could anyone think that strong_parameters was a good idea?!?!!? Just wasted a lot of time on that sigh
Andy Holland
@AMHOL
Mar 07 2016 15:51
Not as much as the guy that wrote it :laughing:
Piotr Solnica
@solnic
Mar 07 2016 15:51
it’s pretty bad, I agree
Hannes Nevalainen
@kwando
Mar 07 2016 15:51
true..
Piotr Solnica
@solnic
Mar 07 2016 15:51
I hope dry-v can be a solid replacement
Hannes Nevalainen
@kwando
Mar 07 2016 15:52
It is already a lot better
Piotr Solnica
@solnic
Mar 07 2016 15:52
oh yeah? did you start using it instead of strong_params?
Andy Holland
@AMHOL
Mar 07 2016 15:52
Just released dry-container 0.3.0 see dryrb/dry-container#11
Piotr Solnica
@solnic
Mar 07 2016 15:52
@AMHOL it’s a breaking change, right?
Andy Holland
@AMHOL
Mar 07 2016 15:53
Don't think so?
Hannes Nevalainen
@kwando
Mar 07 2016 15:53
I have used virtus instead of strong_params for ages, dry-v kicks that up another notch =)
Piotr Solnica
@solnic
Mar 07 2016 15:53
yeah man, virtus was also a bad idea :joy:
Hannes Nevalainen
@kwando
Mar 07 2016 15:53
meh, I got the job done
Piotr Solnica
@solnic
Mar 07 2016 15:53
despite its almost 4M downloads on rubygems :/
Andy Holland
@AMHOL
Mar 07 2016 15:53
virtus was a vast improvement for me when I first found it
Hannes Nevalainen
@kwando
Mar 07 2016 15:54
I=it
Andy Holland
@AMHOL
Mar 07 2016 15:54
Times change
Piotr Solnica
@solnic
Mar 07 2016 15:54
yeah I guess it’s called “progress” :)
Hannes Nevalainen
@kwando
Mar 07 2016 15:56
I developed a pattern where every non trivial controller action have a params object, i.e. "UserIndexParams" which is a virtus object validated with AR validations.. it has cleaned up a lot of code so far.
Piotr Solnica
@solnic
Mar 07 2016 15:57
I used to do the same
now it’s replaced with dry-v
Oskar Szrajer
@gotar
Mar 07 2016 15:57
I do it all the time but with (Virtus, Anima, ... Lotus Validation) combination
Hannes Nevalainen
@kwando
Mar 07 2016 15:57
yeah, I'm migrating too
Oskar Szrajer
@gotar
Mar 07 2016 15:57
but 0 AR, AM ;]
time to migrate for me too
Piotr Solnica
@solnic
Mar 07 2016 15:58
@gotar it’s gonna be a good moment soon, once dry-v 0.7.0 is out
shooting for next week
Hannes Nevalainen
@kwando
Mar 07 2016 15:58
Makes sense to stay with AM-V when caught in rails =/
Piotr Solnica
@solnic
Mar 07 2016 15:58
I’ll be working on OSS almost-full-time next week, so I should get lots of stuff done
Hannes Nevalainen
@kwando
Mar 07 2016 15:58
<3
Michał Pietrus
@blelump
Mar 07 2016 16:05
Hi @solnic , is it possible that Im still getting undefined method 'visit_check' for #<Dry::Validation::InputTypeCompiler for key(:password).required(:filled?, min_size?: 3).confirmation ?
Piotr Solnica
@solnic
Mar 07 2016 16:06
@blelump are you using latest rev from master?
Michał Pietrus
@blelump
Mar 07 2016 16:06
yep
Piotr Solnica
@solnic
Mar 07 2016 16:06
@blelump oops, yeah I missed this case. I’ll fix
Michał Pietrus
@blelump
Mar 07 2016 16:07
thx :-)
Michał Pietrus
@blelump
Mar 07 2016 16:16
and if I can add a a 5cents to the discussion above, I found valuable the dry-types Hashes as the first step of params filtering, e.g:
permitor = Types::Hash
.schema(user_session: Types::Hash
    .strict(email: Types::String, password: Types::String))
permitor[params]
Piotr Solnica
@solnic
Mar 07 2016 16:20
@blelump ok it’s fixed
re params filtering, actually schema should do that for you, which is now a known issue that I’ll address prior 0.7.0 release
Michał Pietrus
@blelump
Mar 07 2016 16:30
@solnic thx :-)