Module: DataMapper::Validations::ValidatesPrimitiveType

Extended by:
Deprecate
Included in:
ClassMethods
Defined in:
lib/dm-validations/validators/primitive_validator.rb

Overview

class PrimitiveTypeValidator

Instance Method Summary collapse

Instance Method Details

#validates_primitive_type_of(*fields) ⇒ Object

Validates that the specified attribute is of the correct primitive type.

Examples:

Usage

require 'dm-validations'

class Person
  include DataMapper::Resource

  property :birth_date, Date

  validates_primitive_type_of :birth_date

  # a call to valid? will return false unless
  # the birth_date is something that can be properly
  # casted into a Date object.
end


51
52
53
# File 'lib/dm-validations/validators/primitive_validator.rb', line 51

def validates_primitive_type_of(*fields)
  validators.add(PrimitiveTypeValidator, *fields)
end