I can’t seem to get filled to work with each. I’m not sure if this should be supported or I’m doing it the wrong way.
Example:
require 'dry-validation'
schema = Dry::Validation.Schema do
required(:foo).filled(:array?).each do
schema do
required(:bar).filled(:str?)
end
end
end
# 1.
p schema.({}).errors
# => {:foo=>["is missing"]}
# 2.
p schema.(foo: []).errors
# => {:foo=>["must be filled"]}
# 3.
p schema.(foo: [1]).errors
# => {}
# 4.
p schema.(foo: [{}]).errors
# => {}
# 5.
p schema.(foo: [{bar: 'baz'}]).errors
# => {}
With the above example I would expect 3. and 4. to return errors related to the internal schema. If I remove the filled(:array?) from the schema the internal schema validates as expected.
Cheers