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


274
275
276
277
278
279
280
# File 'lib/gitlab/config/entry/validators.rb', line 274

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


288
289
290
291
292
# File 'lib/gitlab/config/entry/validators.rb', line 288

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


282
283
284
285
286
# File 'lib/gitlab/config/entry/validators.rb', line 282

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