These are chat archives for dry-rb/chat

29th
May 2017
Tim Riley
@timriley
May 29 2017 02:21
Folks, we’re going to be releasing some big changes to dry-transaction soon. Read about them here (https://discuss.dry-rb.org/t/coming-soon-in-dry-transaction-class-based-transactions/278) and let us know if you have any thoughts.
Gustavo Caso
@GustavoCaso
May 29 2017 05:29
Awesome @timriley
Gustavo Caso
@GustavoCaso
May 29 2017 06:01
I created the first of a series of post talking about dry-web-roda and all the libraries involves to make it work http://gustavocaso.github.io/2017/05/dry-web-roda-for-rails-developers_part_i/ any thoughts, comments, typos etc.. will be much appreciated
Ricardo Bernardeli
@bernardeli
May 29 2017 22:55

Hi all. I'm not sure this is the right channel to ask for help. I'm unsure whether I found a bug in dry-validations or I'm misusing it.

require "dry-struct"
require "dry-types"
require "dry-validation"

module Types
  include Dry::Types.module
end

Dry::Validation.load_extensions(:monads)
Dry::Validation.load_extensions(:struct)

class Flags < Dry::Struct::Value
  attribute :admin, Types::Strict::Bool
end

PersonValidation = Dry::Validation.Schema {
  required(:name).filled(:str?)
  required(:flags).schema(Flags)
}

output = PersonValidation.call({})

puts output.to_either

=> /Users/ric/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/dry-validation-0.10.7/lib/dry/validation/message_set.rb:113:in `[]': no implicit conversion of Symbol into Integer (TypeError)

The expectation was Left({:name=>["is missing"], :flags=>["is missing"]}). Am I missing anything or I hit a bug with schemas + to_either?

Please let me know if this isn't the right channel, and I'll move to the appropriate place. :)
Nikita Shilnikov
@flash-gordon
May 29 2017 23:02
@bernardeli this is the right place :)
please file an issue via GH, I'll address it
for know you can work around this with to_either(hints: false)
I think this should the default behavior
Ricardo Bernardeli
@bernardeli
May 29 2017 23:14
Thanks @flash-gordon