Class: Gitlab::Config::Entry::Validators::VariablesValidator

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

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



322
323
324
325
326
327
328
# File 'lib/gitlab/config/entry/validators.rb', line 322

def validate_each(record, attribute, value)
  if options[:array_values]
    validate_key_array_values(record, attribute, value)
  else
    validate_key_values(record, attribute, value)
  end
end

#validate_key_array_values(record, attribute, value) ⇒ Object



336
337
338
339
340
# File 'lib/gitlab/config/entry/validators.rb', line 336

def validate_key_array_values(record, attribute, value)
  unless validate_array_value_variables(value)
    record.errors.add(attribute, 'should be a hash of key value pairs, value can be an array')
  end
end

#validate_key_values(record, attribute, value) ⇒ Object



330
331
332
333
334
# File 'lib/gitlab/config/entry/validators.rb', line 330

def validate_key_values(record, attribute, value)
  unless validate_variables(value)
    record.errors.add(attribute, 'should be a hash of key value pairs')
  end
end