Module: DataMapper::Validate::ValidatesPresent

Module | DataMapper::Validate::ValidatesPresent
In: | lib/dm-validations/validators/required_field_validator.rb

### Methods

validates_present

### Public Instance methods

validates_present(*fields)

Validates that the specified attribute is present.

For most property types "being present" is the same as being "not blank" as determined by the attribute‘s blank? method. However, in the case of Boolean, "being present" means not nil; i.e. true or false.

@note

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

@see lib/dm-core/support/blank.rb (dm-core) for more information.

@example [Usage]

      require 'dm-validations'

      class Page
        include DataMapper::Resource

        property :required_attribute, String
        property :another_required, String
        property :yet_again, String

        validates_present :required_attribute
        validates_present :another_required, :yet_again

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

[Validate]