by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 17:35
    aka-emi starred dry-rb/dry-monads
  • 09:18
    k0va1 opened #71
  • 08:37
  • May 29 21:51
    armstnp closed #125
  • May 29 21:51
    armstnp commented #125
  • May 29 20:27
    sankalpk starred dry-rb/dry-types
  • May 29 14:43
    josh-dev-test starred dry-rb/dry-types
  • May 28 16:39
    kietnguyen starred dry-rb/dry-types
  • May 27 09:03
    Travis dry-rb/dry-transaction (release-0.13) errored (353)
  • May 26 18:01
    marzdrel starred dry-rb/dry-system
  • May 25 09:50
    k0va1 starred dry-rb/dry-monads
  • May 22 10:57
    solnic commented #146
  • May 21 22:24
    armstnp edited #125
  • May 21 22:23
    armstnp edited #125
  • May 21 22:17
    armstnp labeled #125
  • May 21 22:17
    armstnp opened #125
  • May 21 10:54
    jezstephens commented #146
  • May 21 09:25
    solnic labeled #146
  • May 21 09:23
    solnic commented #146
  • May 20 17:41
    jezstephens labeled #146
Daniel Gollahon
@dgollahon
ah, no. but that could also be helpful in some cases.
my app has a reasonable number of schemas now, but they're starting to grow and they have a good bit of duplication so i'm trying to narrow down a few cases.
Piotr Solnica
@solnic
this is easily doable but I won’t add it unless somebody actually has a use case and reports an issue :)
sure, gimme a sec
Daniel Gollahon
@dgollahon
ok, sometime i'll review the schemas we have and think about what i'd ideally want and when i've got a clearer open an issue or discuss here. like i said, it's not out of hand yet... but i could see the duplication getting that way.
just was curious if there were already more mechanism that i didn't know about beyond just doing .schema(other_schema)
Piotr Solnica
@solnic
require 'dry-validation'

OneSchema = Dry::Validation.Schema do
  required(:name).filled(:str?)
  required(:email).filled(:str?)
end

AnotherSchema = Dry::Validation.Schema(OneSchema) do
  required(:age).value(:int?)
end
@dgollahon ^^
this will prepend rules from OneSchema
Daniel Gollahon
@dgollahon
oh, interesting
that's actually exactly what i was asking about
Piotr Solnica
@solnic
if you have more you can do this too:
Dry::Validation.Schema(Dry::Validation::Schema, rules: SomeSchema.class.rules + OtherSchema.class.rules)
so as you can see, it’s awful :laughing:
Daniel Gollahon
@dgollahon
haha
Piotr Solnica
@solnic
there’s an issue about it
Daniel Gollahon
@dgollahon
that last one is a little awkward, yeah
Piotr Solnica
@solnic
well, it’s just not done yet (hence no docs too)
Daniel Gollahon
@dgollahon
but the first case seems potentially useful. i'll have to tinker with it.
yeah
totally understand
Piotr Solnica
@solnic
this is tricky stuff so it’s taking some time
Daniel Gollahon
@dgollahon
yeah, definitely
Piotr Solnica
@solnic
schemas have all sorts of properties, so it’s not just “use inheritance Luke!”
Daniel Gollahon
@dgollahon
but good to know there's an effort about it.
haha, yeah.
Piotr Solnica
@solnic
well, we just need to come up with an API :)
because internals are ready
Daniel Gollahon
@dgollahon
and "use inheritance Luke!" is also not inherently simple.
cool
Piotr Solnica
@solnic
that too :)
schema rules is just an array with rules, so we can append stuff, prepend stuff, compose with others, whatever we want
and since input processors are decoupled, this doesn’t affect the rules at all
furthermore, message compilation is decoupled too, so we can easily tune message settings for a schema that inherits rules from multiple other schemas that have different message settings :)
Daniel Gollahon
@dgollahon
neat, seems great. just time to do some API pondering.
seems like some of the harder parts will be if you have collisions
where both schema A and B operate on key foo.
Piotr Solnica
@solnic
we can do stuff like [a_rules.select { |r| r.name == :foo } + b_rules.select { |r| r.name == :foo }].reduce(:and)
errrr s/select/detect/
this stuff is crazy flexible so we can either do this, or make it configurable, or raise an error, dunno :)
Daniel Gollahon
@dgollahon
yeah. i would expect you could inadvertently get contradictory rules with an and. but maybe that's just your fault and ohwell :P
might be less surprising to raise an error. but i don't know, there may be a reasonable alternative.
Juanma Cervera
@jmcervera
Hi, A question about testing.
I'm developing a dry-system project, where my functional classes are registered in the app container.
I instantiate the objects in specs through the container as I do in the app.
How should I instantiate the subject object when I want to mock some of the dependencies,
with mocks or lambda functions to avoid for example go to the database through a repository?
Should I instantiate the object with new and not use the DI?
Is there a way to mock only some of the dependencies and get DI work for the others?
just use .new + kwargs (it’s the default constructor type in autoinject)
Juanma Cervera
@jmcervera
@solnic Thanks :smile:
Sergei Novikov
@droptheplot
Hi there! Looks like a have a similar questions but don't know where to start. I'm using containers in my application and currently calling them like container['somenamespace.somecontainer'].call within my specs. The questions is how to use auto_inject inside specs?
Jānis Miezītis
@janjiss
Hey folks, I created a gem main purpose of which is to map data from unformated hash (In my case from CSV rows) and turn it to some usable domain objects and to add dry-types as a basis for type checks. https://github.com/janjiss/massager
Piotr Solnica
@solnic
@janjiss oh cool I’ll check it out. thanks for sharing
Jānis Miezītis
@janjiss
@solnic On which time zone are you? Are you in Krakow or in US atm?