Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Nikita Shilnikov
@flash-gordon
@dsounded I'll revisit supported monads in a while, when I finish the monads chapter in that haskell book ;)
John Backus
@backus
I might be missing something obvious but is there no way on gitter to just search the dry-rb/chat room?
Nikita Shilnikov
@flash-gordon
@backus I bet you're supposed to love new global search, one field for everything
John Backus
@backus
:'(
But every room in gitter is a software room basically
and I want to search deduplicating schemas
Oh it actually worked alright
Maybe the gitter overlords know better
Nikita Shilnikov
@flash-gordon
haha
Joe Van Dyk
@joevandyk
hm, I just tried using dry-validation and I get an exception when requiring the library
Piotr Solnica
@solnic
@joevandyk hey, sorry about that…it’s my fault, pin dry-logic to 0.3.0 for now. I’ll release new validation/types later today
Joe Van Dyk
@joevandyk
dry-rb/dry-validation#256
ah ok
Piotr Solnica
@solnic
I started release process yesterday and didn’t manage to finish, I’ll do it soooon
Joe Van Dyk
@joevandyk
no worries
Joe Van Dyk
@joevandyk
what does the validation look like for validating an array of strings?
(and then an array of strings that contain valid urls)
Piotr Solnica
@solnic
@joevandyk required(:urls).each(:str?, :url?)
Joe Van Dyk
@joevandyk
ah, nice. what about an validating that there's at least one image in the array?
Piotr Solnica
@solnic
@joevandyk required(:urls).value(min_size?: 1) { each(:str?, :url?) }
unfortunately chaining doesn’t work yet, so you gotta use a block
Piotr Solnica
@solnic
@/all hey folks! dry-validation 0.10.0 dry-types 0.9.0 and the new dry-struct 0.1.0 gems have been just released. Please do read CHANGELOGs on GitHub before upgrading :) More info coming soon on our blog!
Tim Riley
@timriley
woooo solnic nice woooooorrrkkkk :tada:
Joe Van Dyk
@joevandyk
how can I validate in dry-validation that a hash has string keys and string values?
Tim Riley
@timriley
I guess you’d need to use the input macro for that
Joe Van Dyk
@joevandyk
/home/monkey/.gem/ruby/2.2.5/gems/dry-validation-0.10.0/lib/dry/validation/schema/value.rb:1:in `require': cannot load such file -- dry/struct (LoadError)
    from /home/monkey/.gem/ruby/2.2.5/gems/dry-validation-0.10.0/lib/dry/validation/schema/value.rb:1:in `<top (required)>'
    from /home/monkey/.gem/ruby/2.2.5/gems/dry-validation-0.10.0/lib/dry/validation/schema.rb:7:in `require'
    from /home/monkey/.gem/ruby/2.2.5/gems/dry-validation-0.10.0/lib/dry/validation/schema.rb:7:in `<top (required)>'
is that expected?
Nikita Shilnikov
@flash-gordon
oops
Joe Van Dyk
@joevandyk
this is when requiring dry-v
Nikita Shilnikov
@flash-gordon
@solnic I pushed a fix ^
just removed that line, I overlooked it, sorry
Joe Van Dyk
@joevandyk
@timriley what's the input macro?
Jānis Miezītis
@janjiss
Folks, I just wanted to say: You are awesome
Nikita Shilnikov
@flash-gordon
:heart:
Piotr Solnica
@solnic
@janjiss <3
@flash-gordon it’d be fine to push 0.10.1 with your fix, I think, wdyt?
@timriley thanks, wasn’t easy, thankfully we’ve got amazing help from contributors :)
now I gotta sum this up in a blog post :sweat_smile:
Nikita Shilnikov
@flash-gordon
@solnic yeah, think so
John Backus
@backus
Good news
I think I found my first dry-v bug of the new release
gem 'dry-validation', '~> 0.10'

require 'dry/validation'

schema =
  Dry::Validation.Schema do
    required(:foo) { str? }
    required(:bar) { str? | int? }
  end

schema.call(foo: 1, bar: 'blah').message_set.first.text # => "must be a string"

begin
  schema.call(foo: 'hi', bar: 1.0).message_set.first.text
rescue => err
  p err
end

# >> #<NoMethodError: undefined method `text' for #<Dry::Validation::Message::Or:0x007fbcb32514b8>>
@solnic or @flash-gordon ^
Is it a bug or were we using private API?
John Backus
@backus
works with #to_s
gem 'dry-validation', '~> 0.10'

require 'dry/validation'

SCHEMA =
  Dry::Validation.Schema do
    required(:foo) { str? }
    required(:bar, %i[string int]) { str? | int? }
  end

SCHEMA.call(foo: 1, bar: 'blah').message_set.first.to_s # => "must be a string"

begin
  SCHEMA.call(foo: 'hi', bar: 1.0).message_set.first.to_s # => "must be a string or must be an integer"
rescue => err
  p err
end
Piotr Solnica
@solnic
@backus #to_s should be used, not text
there’s also Result#errors and Result#hints