diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-02-13 19:46:02 +0100 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-02-13 23:51:04 +0100 |
commit | 9a5ba5c67444d9b71597dd8c43955a055a047100 (patch) | |
tree | 166b3a5fa51aa62d081c91a39aa7580d56e44085 /app/validators | |
parent | a4b843e9b844ed4e3a5f204e3fb5f43c68fd2db8 (diff) | |
download | gitlab-ce-9a5ba5c67444d9b71597dd8c43955a055a047100.tar.gz |
Add more information in variable_duplicates validator error message
Diffstat (limited to 'app/validators')
-rw-r--r-- | app/validators/variable_duplicates_validator.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/validators/variable_duplicates_validator.rb b/app/validators/variable_duplicates_validator.rb index 7887b217829..ae9ebdf28cf 100644 --- a/app/validators/variable_duplicates_validator.rb +++ b/app/validators/variable_duplicates_validator.rb @@ -20,7 +20,9 @@ class VariableDuplicatesValidator < ActiveModel::EachValidator def validate_duplicates(record, attribute, values) duplicates = values.reject(&:marked_for_destruction?).group_by(&:key).select { |_, v| v.many? }.map(&:first) if duplicates.any? - record.errors.add(attribute, "Duplicate variables: #{duplicates.join(", ")}") + error_message = "has duplicate variables (#{duplicates.join(", ")})" + error_message += " in #{options[:scope]} scope" if options[:scope] + record.errors.add(attribute, error_message) end end end |