dry-validation: Predicate :number? inside "each" macro causes errors

Predicate number? used inside each macro causes TypeError while calling #messages method. Here’s how to reproduce an error:

Fails for :number?

FailureWithNumberSchema = Dry::Validation.Schema do
  key(:items).each do
    key(:value).required(:number?)
  end
end

FailureWithNumberSchema.call({}).messages
# => TypeError: no implicit conversion of Hash into Array

Works well with :str?

SuccessWithStringSchema = Dry::Validation.Schema do
  key(:items).each do
    key(:value).required(:str?)
  end
end

SuccessWithStringSchema.call({}).messages
# => {:items=>["is missing"]}

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

please test from master if you can, should be good now. yet another reason to remove nested-keys syntax ha-ha