```ruby
require "active_model"

class TypeValidator < ActiveModel::EachValidator
  def options
    super.merge(allow_nil: true)
  end

  def validate_each(record, attribute, value)
    unless value.is_a?(options[:with])
      record.errors.add(attribute, "must be a #{options[:with]}, not #{value.class}")
    end
  end
end
```

Support multi types in TypeValidator
user
```ruby
require "active_model"

class TypeValidator < ActiveModel::EachValidator
  def options
    super.merge(allow_nil: true)
  end

  def validate_each(record, attribute, value)
    classes = options[:in] || [options[:with]]
    if classes.all? { |klass| !value.is_a?(klass) }
      record.errors.add(attribute, "must be a #{classes.join(' or ')}, not a #{value.class}")
    end
  end
end
```
assistant