Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
John Backus
@backus
Small gotcha that I just ran into
require 'dry/types'

type = Dry::Types::Definition.new(Object)

class Foo
end

class Decorator < SimpleDelegator
end

type.try(Foo.new).success?                # => true
type.try(Decorator.new(Foo.new)).success? # => false
Not totally sure what behavior I think is correct here!
SimpleDelegator does inherit from BasicObject so that is why this happens
The practical part of me doesn't want to think about the fact that SimpleDelegator is a BasicObject
but also it seems like special casing delegators might be weird
thoughts @solnic @flash-gordon?
Nikita Shilnikov
@flash-gordon
@backus heh, yes, Types::Object isn't meant to do any checks, it should act as Identity, i.e. -> (v) { v }. I'd say this is a bug. I think we should rename it to Types::Any or Types::Bottom for clarity
John Backus
@backus
We have it aliased to Types::Any it our app
so I'd endorse Any
Nikita Shilnikov
@flash-gordon
yeah bottom is too geeky :)
John Backus
@backus
heh
Nikita Shilnikov
@flash-gordon
but maybe we could attract some folks from Haskell with that lol
John Backus
@backus
I write Ruby so I don't have to read wikipedia pages about category theory :P
John Backus
@backus
Haha same bug just bit me again
Adam Gwozdowski
@agwozdowski

Hi, I have simple configuration:

class App
  extend Dry::Configurable

  setting :redis do
    setting :url
  end

  setting :name
end

And validation schema:

ConfigurationSchema = Dry::Validation.Schema do
  required(:name).maybe(:str?)
  required(:redis).schema do
    required(:url).maybe(:str?)
  end
end

When I run:

ConfigurationSchema.(App.config.to_h).inspect

Receive error:
errors={:redis=>[\"must be a hash\"]}

Because to_h method doesn't change NestedConfig into hash. What is the best way to handle this case? Thanks for help!

Adam Gwozdowski
@agwozdowski
And one more question. Why, when I set default value false config return nil?
require 'dry-validation'
class App
  extend Dry::Configurable
  setting :name, false
end
App.config.name
Andy Holland
@AMHOL
@agwozdowski that was fixed dry-rb/dry-configurable@3948c0d, just hasn't been released yet
Adam Gwozdowski
@agwozdowski
Thanks @AMHOL! Do you know how to handle previous problem, with to_h method? :)
Piotr Solnica
@solnic
ah yes, @mensfeld is a happy dry-v user :)
Andy Holland
@AMHOL
@agwozdowski I just released dry-configurable 0.7.0, try updating, it should work then
Maciej Mensfeld
@mensfeld
@AMHOL I'm a very, very happy dry user :) @agwozdowski and I use it in Karafka framework as well (http://github.com/karafka/karafka)
Andy Holland
@AMHOL
@mensfeld that's good to hear, glad you're liking it, feel free to drop me a PM or open an issue if there's anything you feel could be better :)
https://github.com/karafka/karafka looks good, haven't used kafka before
Maciej Mensfeld
@mensfeld
@AMHOL thanks :) Kafka is really, really good - I have one system that works on the combination of Karafka + Dry-v + Dry-c
and you guys do a great job in terms of quality and development - I track some metrics about dry organization and really :clap:
Andy Holland
@AMHOL
Oh, that's awesome, would be interested in hearing more about that, enjoyed your blog post BTW :)
Maciej Mensfeld
@mensfeld
Thanks. Some people complain about more complex cases but I have one lkke that: multinested hash with internal structures + I validate it 100-5000x per second and it works :)
Andy Holland
@AMHOL
That's impressive :)
@solnic ^^
Maciej Mensfeld
@mensfeld
about the metrics and data - I'm planning to give it to you as a way to say thank you. I just need a bit more time to aggregate it in a nice way
Andy Holland
@AMHOL
Oh wow <3
Piotr Solnica
@solnic
data validation is such a complex domain that it’s gonna take years to cover maybe 80% of the cases people have heh
we have almost 3000 spec examples in dry-v repo and honestly we probably barely cover 60% of the currently supported use cases
this is pretty much crazy stuff
one thing I’d like to do in 1.0 is to simplify DSL so that there’s less ways of…doing things O_o
high level rules will definitely go away from schemas, that’ll make things much simpler already
one of the challenges is to have a DSL that is concise yet it can be 100% flexible, that’s tricky
and I don’t even want to mention cases like dynamic data structures, as in, structures that must match a pattern, instead of a strict definition
and yes folks have been asking for this :laughing:
Maciej Mensfeld
@mensfeld
@solnic I cover 100% of mine so if you change anything and need to hve external specs I can run mine for you ;)
Piotr Solnica
@solnic
sounds like a plan ;)
Maciej Mensfeld
@mensfeld
@apotonick ask me to do that from time to time as I hve 100% coverage of operations as well
Since your gems aren't considered stable by me - I prefer to cover all the things
Piotr Solnica
@solnic
you sure you wanted to mention Nick ^_^? :D
Maciej Mensfeld
@mensfeld
hahaha :P
will something bad happen?
Piotr Solnica
@solnic
anyhow, yes dry-rb gems are not stable