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


63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/gitlab/config/entry/validators.rb', line 63

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