Class: Gitlab::Config::Entry::Validators::AllowedKeysValidator

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


8
9
10
11
12
13
14
15
# File 'lib/gitlab/config/entry/validators.rb', line 8

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

  if unknown_keys.any?
    record.errors.add(attribute, "contains unknown keys: " +
                                  unknown_keys.join(', '))
  end
end