Class: Gitlab::Config::Entry::Validators::AlphanumericValidator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.validate(value) ⇒ Object



344
345
346
# File 'lib/gitlab/config/entry/validators.rb', line 344

def self.validate(value)
  value.is_a?(String) || value.is_a?(Symbol) || value.is_a?(Integer)
end

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



348
349
350
351
352
# File 'lib/gitlab/config/entry/validators.rb', line 348

def validate_each(record, attribute, value)
  unless self.class.validate(value)
    record.errors.add(attribute, 'must be an alphanumeric string')
  end
end