Skip to content

Commit

Permalink
Merge 095b2cf into ced64ea
Browse files Browse the repository at this point in the history
  • Loading branch information
jonspalmer committed Nov 17, 2019
2 parents ced64ea + 095b2cf commit c81737f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -71,3 +71,4 @@
[@blaze182]: https://github.com/blaze182
[@zokioki]: https://github.com/zokioki
[@keithpitt]: https://github.com/keithpitt
[@bostanio]: https://github.com/bostanio
2 changes: 1 addition & 1 deletion lib/active_model/validations/store_model_validator.rb
Expand Up @@ -24,7 +24,7 @@ def validate_each(record, attribute, value)
when :json
strategy.call(attribute, record.errors, value.errors) if value.invalid?
when :array
record.errors.add(attribute, :invalid) if value.any?(&:invalid?)
record.errors.add(attribute, :invalid) if value.select(&:invalid?).present?
end
end

Expand Down
5 changes: 4 additions & 1 deletion spec/active_model/validations/store_model_validator_spec.rb
Expand Up @@ -84,7 +84,7 @@
end

context "when array member is invalid" do
let(:attributes) { { configuration: [Configuration.new] } }
let(:attributes) { { configuration: [Configuration.new, Configuration.new] } }

it { is_expected.to be_invalid }

Expand All @@ -94,6 +94,9 @@

expect(subject.configuration.first.errors.messages).to eq(color: ["can't be blank"])
expect(subject.configuration.first.errors.full_messages).to eq(["Color can't be blank"])

expect(subject.configuration.second.errors.messages).to eq(color: ["can't be blank"])
expect(subject.configuration.second.errors.full_messages).to eq(["Color can't be blank"])
end
end

Expand Down

0 comments on commit c81737f

Please sign in to comment.