Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
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:
Sergey 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?
Just curiosity - Since your work hours look more like US, but under profile there is Krakow :D
Piotr Solnica
@solnic
@janjiss US atm
Christopher Dennl-Ortega Arrieta
@cdennl
@solnic Is it allowed to have multiple predicates( My::Predicates ) statements in the config block auf a schema?
Piotr Solnica
@solnic
@cdennl it’s config.predicates = YourPredicates since 0.9.x
or 0.8.0 O_o can’t remember exactly
oh and no, it doesn’t support more than one predicate module, at least not yet
Christopher Dennl-Ortega Arrieta
@cdennl
it is predicates(...) in 0.9+ :) and thank you I saw that only one is working at the moment
Piotr Solnica
@solnic
Ah right, I kept it eventually. Sorry, too much on my mind :)
Michał Gutowski
@CucumisSativus
Hey guys, in dry-types is there built-in way to make your own type to behave like a Maybe type?
Nikita Shilnikov
@flash-gordon
@CucumisSativus wdym by saying "behave like"?
Michał Gutowski
@CucumisSativus
@flash-gordon that it will return None if nothing is there and returns object if needed
s/needed/present
Nikita Shilnikov
@flash-gordon
yeah, but it will be wrapped with Some. dry-t has optional types ootb, so you can have your value or nil, wo wrapping it with a monadic interface
Krzysztof Wawer
@wafcio
I am reading dry-validation docs and sometimes I see require(:name).filled and sometimes I see require(:name).value(:filled) what is difference between these two syntax ?
Krzysztof Wawer
@wafcio
moreover sometimes you are using filled and filled?
Christopher Dennl-Ortega Arrieta
@cdennl
@solnic Why do I get a exception on this?
rule( check_comment_on_reject: [ :is_accepted, :comment ] ) do |is_accepted, comment|
          is_accepted.false? > comment.filled?
        end
in `block (3 levels) in <class:CreateSubmissionReview>': undefined method `then' for false:FalseClass (NoMethodError)
    from /usr/local/rvm/gems/ruby-2.3.1/gems/dry-validation-0.9.5/lib/dry/validation/schema/value.rb:95:in `instance_exec'
    from /usr/local/rvm/gems/ruby-2.3.1/gems/dry-validation-0.9.5/lib/dry/validation/schema/value.rb:95:in `rule'
Christopher Dennl-Ortega Arrieta
@cdennl
required( :is_accepted ).filled( :bool? )
optional( :comment ).maybe( :str?, size?: (5..2000) )
I also get the same eror on this one:
required( :user ).filled
required( :challenge ).filled( :is_opened?, :is_in_review_time_frame? )
required( :participation ).filled( :has_video_submission? )

rule( check_self_review: [ :user, :challenge, :participation ] ) do |user, challenge, participation|
          ( !user.is_host?( challenge ) & user.is_participant?( challenge ) ).then( user.does_no_self_review?( participation ) )
        end
Christopher Dennl-Ortega Arrieta
@cdennl
I'd be glad for feedback, but thanks to predicate logic i can workaround with this identity: a > b == !a | b :)
mh unfortunately the workaround doesnt work either
/usr/local/rvm/gems/ruby-2.3.1/gems/dry-validation-0.9.5/lib/dry/validation/schema/value.rb:98:in `rule': undefined method `with' for true:TrueClass (NoMethodError)
    from /var/www/gamebet/app/concepts/submission_review/operation/create.rb:49:in `block (2 levels) in <class:Create>'
    from /usr/local/rvm/gems/ruby-2.3.1/gems/dry-validation-0.9.5/lib/dry/validation/schema/class_interface.rb:46:in `instance_exec'
    from /usr/local/rvm/gems/ruby-2.3.1/gems/dry-validation-0.9.5/lib/dry/validation/schema/class_interface.rb:46:in `define'
Michał Gutowski
@CucumisSativus
@flash-gordon oh crap it was much easier than i thought
Nikita Shilnikov
@flash-gordon
:grin:
Piotr Solnica
@solnic
@cdennl hmm could you report an issue with a repro script?
Piotr Solnica
@solnic
@wafcio we shouldn’t show required(:name).value(:filled?) as required(:name).filled is a shorter equivalent, where did you see it exactly?
Kimmo Lehto
@kke
great. "dry-monads-0.2.0 requires ruby version >= 2.1.0, which is incompatible with the..."
Kimmo Lehto
@kke
every week our installs break because of dry dependencies, grr!
John Backus
@backus
@kke Do you have a question or are you just venting? It shouldn't break your build if you lock it to your minor version. The gem is not 1.0 so there aren't any guarantees
Kimmo Lehto
@kke
mostly venting.