Hi all,
Using dry-validation 0.9.2 errors from rules no longer nest correctly:
NestedSchema = Dry::Validation.Schema {
required(:user).schema do
required(:email).filled
required(:password).filled
required(:password_confirmation).filled
rule(passwords_match: [:password, :password_confirmation]) { |p1, p2| p1.eql?(p2) }
end
}
result = NestedSchema.call(user: {password: 'foo', password_confirmation: 'bar'})
expect(result.messages.fetch(:user).fetch(:email)).to eq(['is missing']) # => passes
expect(result.messages.fetch(:user).fetch(:password)).to eq(['must be equal to bar']) # => fails
Should this work?
Cheers,
Theo