Class: Gitlab::Config::Entry::Validators::OnlyOneOfKeysValidator

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



44
45
46
47
48
49
50
51
# File 'lib/gitlab/config/entry/validators.rb', line 44

def validate_each(record, attribute, value)
  present_keys = value.try(:keys).to_a

  unless options[:in].one? { |key| present_keys.include?(key) }
    record.errors.add(attribute, "must use exactly one of these keys: " +
      options[:in].join(', '))
  end
end