Skip to content

Commit 420a1a4

Browse files
author
Lee Richmond
committed
Support multiple errors on same attribute
1 parent 3ebcc46 commit 420a1a4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/jsonapi_spec_helpers/helpers.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,14 @@ def json_ids(integers = false)
5757
def validation_errors
5858
@validation_errors ||= {}.tap do |errors|
5959
json['errors'].each do |e|
60-
errors[e['meta']['attribute'].to_sym] = e['meta']['message']
60+
attr = e['meta']['attribute'].to_sym
61+
message = e['meta']['message']
62+
63+
if errors[attr]
64+
errors[attr] = Array(errors[attr]).push(message)
65+
else
66+
errors[attr] = message
67+
end
6168
end
6269
end
6370
end

0 commit comments

Comments
 (0)