Class: Gitlab::Config::Entry::Validators::DisallowedKeysValidator

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


19
20
21
22
23
24
25
26
27
28
# File 'lib/gitlab/config/entry/validators.rb', line 19

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

  if present_keys.any?
    message = options[:message] || "contains disallowed keys"
    message += ": #{present_keys.join(', ')}"

    record.errors.add(attribute, message)
  end
end