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



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

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, "please use only one of the following keys: " +
      mutually_exclusive_keys.join(', '))
  end
end