Commit 48db60e4 authored by Matija Čupić's avatar Matija Čupić

Refactor variable duplicates error message

parent 9a5ba5c6
...@@ -21,7 +21,7 @@ class VariableDuplicatesValidator < ActiveModel::EachValidator ...@@ -21,7 +21,7 @@ class VariableDuplicatesValidator < ActiveModel::EachValidator
duplicates = values.reject(&:marked_for_destruction?).group_by(&:key).select { |_, v| v.many? }.map(&:first) duplicates = values.reject(&:marked_for_destruction?).group_by(&:key).select { |_, v| v.many? }.map(&:first)
if duplicates.any? if duplicates.any?
error_message = "has duplicate variables (#{duplicates.join(", ")})" error_message = "has duplicate variables (#{duplicates.join(", ")})"
error_message += " in #{options[:scope]} scope" if options[:scope] error_message += " for #{values.first.send(options[:scope])} scope" if options[:scope] # rubocop:disable GitlabSecurity/PublicSend
record.errors.add(attribute, error_message) record.errors.add(attribute, error_message)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment