Class: Gitlab::Config::Entry::Validators::MutuallyExclusiveKeysValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/gitlab/config/entry/validators.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



56
57
58
59
60
61
62
# File 'lib/gitlab/config/entry/validators.rb', line 56

def validate_each(record, attribute, value)
  mutually_exclusive_keys = value.try(:keys).to_a & options[:in]

  if mutually_exclusive_keys.length > 1
    record.errors.add(attribute, "these keys cannot be used together: #{mutually_exclusive_keys.join(', ')}")
  end
end