class Threatinator::Model::Validations::TypeValidator

Public Class Methods

new(options) click to toggle source
Calls superclass method
# File lib/threatinator/model/validations/type.rb, line 8
def initialize(options)
  @type = options.delete(:with)
  super
end

Public Instance Methods

validate_each(record, name, value) click to toggle source
# File lib/threatinator/model/validations/type.rb, line 13
def validate_each(record, name, value)
  unless value.is_a?(@type)
    record.errors.add name, "Expected to be #{@type}, got #{value.class} #{value.inspect}"
  end
end