by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 07:36
    dry-bot commented #151
  • 07:35
    timriley opened #151
  • 07:33

    timriley on bootable-paths

    Remove unused method Remove more methods for now Tr… Switch out system_dir for boota… and 2 more (compare)

  • Aug 12 07:59
  • Aug 11 19:59
    esparta commented #132
  • Aug 11 16:30
    philipce closed #132
  • Aug 11 16:30
    philipce commented #132
  • Aug 11 07:47
    esparta commented #132
  • Aug 11 07:29
    esparta commented #132
  • Aug 11 07:28
    esparta commented #132
  • Aug 11 01:30
    philipce labeled #132
  • Aug 11 01:30
    philipce opened #132
  • Aug 10 18:51
    gbrlcustodio starred dry-rb/dry-monads
  • Aug 10 10:49

    solnic on master

    Fix redefinition warnings happe… Merge pull request #150 from es… (compare)

  • Aug 10 10:49
    solnic closed #150
  • Aug 10 07:58
    esparta edited #150
  • Aug 10 07:58
    esparta edited #150
  • Aug 10 07:51
    esparta opened #150
  • Aug 09 16:13
    charly starred dry-rb/dry-initializer
  • Aug 09 03:48
    slashpai starred dry-rb/dry-system
Piotr Solnica
@solnic
there are LOTS of common patterns for data validation and we can have lots and lots of macros that are doing really complex checks and can be expressed on a single line
we’ll get there
Christopher Dennl-Ortega Arrieta
@cdennl
@solnic I am perfectly fine with arbitrary validation blocks and removing high_lvel rules
sounds good
Piotr Solnica
@solnic
one thing though - the idea is the same, I was talking about specifics of the DSL exclusively
so rule + predicate DSL or just validate with arbitrary code
high level rule as a concept is exactly the same
Christopher Dennl-Ortega Arrieta
@cdennl
ok
I can live with both :) most often I try to avoid too fancy things anyway when it is not necessary
Muhammad Hilmy Fauzan
@muhifauzan
Guys, how can I make high level rule in nested schema that check value from parent schema?
Rafael George
@cored
is there a way in virtus for me to call all my attributes value objects to_s when I do .to_h
I wrote something like def to_h; super.merge(field: value_object.to_s)
but looks kinda hacky don't know if there's a declarative way of doing such thing
Daniel Gollahon
@dgollahon

Hi. Is there a way to create anonymous rules in dry-validations? Or do i have to specify them as:

rule(name: %i[args])

I'm not saying this should be a feature, just curious if it exists. I have a case where I'm validating something but do not at all care about the error messages, only whether or not the thing is valid. I also use mutant in CI and it complains that it can rename the argument name__mutant__. I can expose the schema and expect something about it to kill the mutant, but if there already happens to be a way to define the rule anonymously, that'd be cool.

Daniel Gollahon
@dgollahon
Also, just a bit of positive feedback on dry-v. I had a validation I had to do that involved a bit of awkward boolean logic that was dramatically simplified by having > available. Made working on a validation task I had today fun instead of frustrating :D
Don Morrison
@elskwid
@cored I’d make a new method that does that and you can access the attribute_set and attributes on the instance.
Piotr Solnica
@solnic
@dgollahon this is an interesting use-case that I haven’t thought about, could you please report an issue about this?
Daniel Gollahon
@dgollahon
@solnic the anonymous rule?
Piotr Solnica
@solnic
@dgollahon re your positive feedback, thank you, it made my day <3 :)
@dgollahon yes :)
Daniel Gollahon
@dgollahon
sure, i'll open an issue in a couple of minutes. :)
@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: