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


260
261
262
263
264
265
266
267
268
# File 'lib/gitlab/config/entry/validators.rb', line 260

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