by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 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
  • May 20 17:41
    jezstephens opened #146
  • May 19 21:29
  • May 19 13:26
    Springok starred dry-rb/dry-monads
  • May 16 22:52
    flash-gordon commented #402
  • May 16 22:51

    flash-gordon on master

    Fix Constructor custom method d… Merge pull request #402 from ti… (compare)

  • May 16 22:51
    flash-gordon closed #402
  • May 16 19:02
    timstott commented #401
  • May 16 18:59
    timstott opened #402
Daniel Gollahon
@dgollahon
@solnic: great. :) I've been working with dry-validation all morning and it's been my favorite coding task of the week so far.
Piotr Solnica
@solnic
w00t :) I’ll be releasing 0.10.0 tomorrow/Friday
Daniel Gollahon
@dgollahon
awesome :)
Daniel Gollahon
@dgollahon
Is there a way to append to a schema? Or have another schema mixed in? (for instance, I might have something that validates a and b in one schema and something that validates a, b, and c in another and right now I duplicate the logic for a and b. In this case the common attributes are top level, not reused objects like you can nest schemas for (as suggested here http://dry-rb.org/gems/dry-validation/reusing-schemas/).
*copy and then append to, actually
Piotr Solnica
@solnic
@dgollahon it is possible but I haven't come up with a nice API for that so it is kinda rough atm. I will show you how a bit later today, not in front of my laptop now
Daniel Gollahon
@dgollahon
@solnic: great, thanks. :)
Piotr Solnica
@solnic
@dgollahon wait, you want to inherit them how exactly?
@dgollahon ie if you have rules for a in two schemas, you’d like to AND them?
Daniel Gollahon
@dgollahon

Well, mainly looking to understand all the reuse options available because i only know what's in that docs page^

In this case i basically want the equivalence of inheritance and I was unsure if you could do something like that. a, b, and c just represent different keys I want to validate. If object A has the a and b attributes and object B has A's attributes plus a new one, c, I'd like to be able to reuse my a and b validations.

or something like a mixin if i have year, month, day attributes in multiple places i might like to mixin the date schema i've built.
for a date with year, month, and day though it's likely they'd be in a separate object and i could use the reuse mechanism from the docs
but i have a few equivalent cases where i have more than one object with common "flat" attributes
does that make sense?
Piotr Solnica
@solnic
@dgollahon I see, I thought you had two schemas with rules for the same key and wanted somehow to combine those
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.