summaryrefslogtreecommitdiff
path: root/app/validators
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-02-18 21:54:55 +0100
committerMatija Čupić <matteeyah@gmail.com>2018-02-22 23:09:24 +0100
commitc65529e8f66bf5367ad2d989a556bf766701d7b9 (patch)
tree51a763cfd87e918128390a83e1439eac0f35c4f6 /app/validators
parent4319b15a78be70ccabb31a25ffba37f77de27b28 (diff)
downloadgitlab-ce-c65529e8f66bf5367ad2d989a556bf766701d7b9.tar.gz
Skip variables duplicates validator if variable is already a duplicate
Diffstat (limited to 'app/validators')
-rw-r--r--app/validators/variable_duplicates_validator.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/app/validators/variable_duplicates_validator.rb b/app/validators/variable_duplicates_validator.rb
index 4bfa3c45303..72660be6c43 100644
--- a/app/validators/variable_duplicates_validator.rb
+++ b/app/validators/variable_duplicates_validator.rb
@@ -5,6 +5,8 @@
# - Use `validates :xxx, uniqueness: { scope: :xxx_id }` in a child model
class VariableDuplicatesValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
+ return if record.errors.include?(:"#{attribute}.key")
+
if options[:scope]
scoped = value.group_by do |variable|
Array(options[:scope]).map { |attr| variable.send(attr) } # rubocop:disable GitlabSecurity/PublicSend