These are chat archives for dry-rb/chat

18th
Sep 2016
Michał Gutowski
@CucumisSativus
Sep 18 2016 14:59
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
Sep 18 2016 17:18
@CucumisSativus wdym by saying "behave like"?
Michał Gutowski
@CucumisSativus
Sep 18 2016 17:43
@flash-gordon that it will return None if nothing is there and returns object if needed
s/needed/present
Nikita Shilnikov
@flash-gordon
Sep 18 2016 17:54
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
Sep 18 2016 18:08
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
Sep 18 2016 18:28
moreover sometimes you are using filled and filled?
Christopher Dennl-Ortega Arrieta
@cdennl
Sep 18 2016 18:50
@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
Sep 18 2016 19:05
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
Sep 18 2016 19:55
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
Sep 18 2016 20:46
@flash-gordon oh crap it was much easier than i thought
Nikita Shilnikov
@flash-gordon
Sep 18 2016 20:46
:grin:
Piotr Solnica
@solnic
Sep 18 2016 22:47
@cdennl hmm could you report an issue with a repro script?