Module: DataMapper::Validate::ValidatesAbsent

Included in:
ClassMethods
Defined in:
lib/gems/dm-validations-0.9.9/lib/dm-validations/absent_field_validator.rb

Overview

class AbsentFieldValidator

Instance Method Summary collapse

Instance Method Details

#validates_absent(*fields) ⇒ Object

Note:

dm-core’s support lib adds the #blank? method to many classes,

Validates that the specified attribute is “blank” via the attribute’s #blank? method.

Examples:

Usage
require 'dm-validations'

class Page
  include DataMapper::Resource

  property :unwanted_attribute, String
  property :another_unwanted, String
  property :yet_again, String

  validates_absent :unwanted_attribute
  validates_absent :another_unwanted, :yet_again

  # a call to valid? will return false unless
  # all three attributes are blank
end

See Also:

  • (dm-core) for more information.


53
54
55
56
# File 'lib/gems/dm-validations-0.9.9/lib/dm-validations/absent_field_validator.rb', line 53

def validates_absent(*fields)
  opts = opts_from_validator_args(fields)
  add_validator_to_context(opts, fields, DataMapper::Validate::AbsentFieldValidator)
end