Hey guys, should the following not be possible? What do I do wrong?
type_a = Dry::Validation.JSON do
required(:type).filled(format?: /\AA\z/)
end
type_b = Dry::Validation.JSON do
required(:type).filled(format?: /\AB\z/)
end
schema = Dry::Validation.JSON do
required(:data).each { schema(type_a) | schema(type_b) }
end
input = {
data: [
{ type: 'A' },
{ type: 'B' },
{ type: 'C' }
]
}
schema.call(input).errors
NoMethodError: undefined method `path' for #<Array:0x00000001eecd60>
Seems like an array is being passed to the message class
dry-validation-0.10.3/lib/dry/validation/message.rb:24:in `initialize'
And it tries to call path on the array. Of course this only happens in the case when the input is invalid.