Class: Gitlab::Config::Entry::Validators::ArrayOfStringsValidator

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



86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/gitlab/config/entry/validators.rb', line 86

def validate_each(record, attribute, value)
  valid = validate_array_of_strings(value)

  record.errors.add(attribute, 'should be an array of strings') unless valid

  if valid && options[:with]
    unless value.all? { |v| v =~ options[:with] }
      message = options[:message] || 'contains elements that do not match the format'
      record.errors.add(attribute, message)
    end
  end
end