Class: Gitlab::Config::Entry::Validators::TypeValidator

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

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



308
309
310
311
312
313
314
315
316
# File 'lib/gitlab/config/entry/validators.rb', line 308

def validate_each(record, attribute, value)
  type = options[:with]
  raise unless type.is_a?(Class)

  unless value.is_a?(type)
    message = options[:message] || "should be a #{type.name}"
    record.errors.add(attribute, message)
  end
end