class ValidatedObject::Base::TypeValidator

A custom validator which ensures an object is an instance of a class or a subclass. It supports a pseudo-boolean class for convenient validation. (Ruby doesn’t have a built-in Boolean.)

Automatically used in a ‘type` validation:

@example Ensure that weight is a number

class Dog < ValidatedObject::Base
  attr_accessor :weight, :neutered
  validates :weight, type: Numeric  # Typed and required
  validates :neutered, type: Boolean, allow_nil: true  # Typed but optional
end