Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 07:54
    flash-gordon commented #115
  • 05:40
    wpzero starred dry-rb/dry-monads
  • 05:30
    dilcom opened #375
  • 02:18
    johnmaxwell edited #115
  • 02:18
    johnmaxwell edited #115
  • Dec 08 23:10
    johnmaxwell labeled #115
  • Dec 08 23:10
    johnmaxwell opened #115
  • Dec 07 14:03

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 10:01
    Travis dry-rb/dry-view (master) errored (636)
  • Dec 07 09:58
    Travis dry-rb/dry-view (master) errored (635)
  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

Oskar Szrajer
@gotar
just pack class around it
require "dry-validation"

module Validations
  class PostValidator
    PostSchema = Dry::Validation.Form do
      required(:title) { filled? & str? }
      required(:body){ filled? & str? }
    end

    def call(args)
      PostSchema.call(args)
    end
  end
end
Piotr Solnica
@solnic
I don't register schemas in containers
just set them as constants
Andy Holland
@AMHOL
@gotar you can pass a block to auto_register!
And use that to determine how to construct the objects
@solnic perhaps we should have a configuration and delegate that to an object
Piotr Solnica
@solnic
better to skip auto-registering schemas
just define them as constants
that's why I added block syntax for building an object
Andy Holland
@AMHOL
How come @solnic ?
Oskar Szrajer
@gotar
it will be the best if AutoInject recognize it's class or not and then defind as contant not call new on it
Andy Holland
@AMHOL
@gotar just watching your wroc_love.rb talk BTW :)
Piotr Solnica
@solnic
link pls?
Oskar Szrajer
@gotar
nothing to see :p
:cat2:
Andy Holland
@AMHOL
lol I'm sure you're being humble
Piotr Solnica
@solnic
@AMHOL it didn't feel right to use a container for things like schemas or data classes like structs and values, they are treated as app boundaries, not some "abstract service objects" that your app relies on
Andy Holland
@AMHOL
Interesting
What about using them in dry-transaction?
Piotr Solnica
@solnic
so ie whenever I see a require "some_app/validation/some_schema" I know that this thing works at a specific boundary of my system
I never used as a schema as a separate step
Andy Holland
@AMHOL
Ahh OK
You just use them in commands?
Piotr Solnica
@solnic
it's always an object that uses a schema internally and typically talks to a db through a repo or command or sutin
Andy Holland
@AMHOL
That makes sense
Piotr Solnica
@solnic
a...service object :P
one thing I still don't like is that this still mixes an http-specific schema with a lower-level app stuff
not sure how to make this nicer
w/o any duplication
Andy Holland
@AMHOL
Still not sure about the not registering them, it's still a dependency, but I don't have experience using dry-component yet
A separate transaction step? :joy:
Piotr Solnica
@solnic
@AMHOL for me it's not an abstract dependency, that's where I draw the line
think about an ActiveRecord model, it's also a boundary, and a really huge one, everywhere your code references an AR model it makes it clear that a given part of your app is coupled to a database
it's the same here, everywhere you use a schema that validates data coming from an http request it's pretty clear that this is part of your system that deals with http stuff
fwiw you could treat that as an abstract concept and only rely on its interface but I think it's an overkill
Andy Holland
@AMHOL
Yeah, I've backed myself into a corner many times trying to be too strict about things, and past experience would indicate that when I disagree with you I'm wrong lol
But I was still thinking in terms of the interface
Still not sure on that one, will have to try it out sometime I guess
Piotr Solnica
@solnic
well, we can both be right :D
I can make dry-v schemas work with auto-registration, but I don't want to ;)
Andy Holland
@AMHOL
BTW, what do you think of pre-configuring a key mapping in component?
Piotr Solnica
@solnic
wdym?
Andy Holland
@AMHOL
To allow registration under keys that don't have any relation to the class name
Piotr Solnica
@solnic
yeah we can use some configurable strategies for figuring this out
Andy Holland
@AMHOL
sth like
Dry::Component.configure do |config|
  config.mapping = {
    'user_validator' => 'users.validator'
  }
end
Then when it loads UserValidator it registers under users.validator
Rather than just computing keys from the constant name
It's a bad example, but the idea is that it allows for more abstract keys
Andy Holland
@AMHOL
Or perhaps just allow for a custom component loader