Module: DataMapper::Validations::ValidatesPresence

### Home Classes Methods

### In Files

- lib/dm-validations/validators/required_field_validator.rb

### Methods

- #validates_presence_of

### Files

- LICENSE
- README.rdoc

### Class/Module Index

Quicksearch

- DataMapper
- DataMapper::InvalidContextError
- DataMapper::Validate
- DataMapper::ValidationError
- DataMapper::Validations
- DataMapper::Validations::AbsenceValidator
- DataMapper::Validations::AcceptanceValidator
- DataMapper::Validations::AutoValidations
- DataMapper::Validations::AutoValidations::ModelExtension
- DataMapper::Validations::ClassMethods
- DataMapper::Validations::ConfirmationValidator
- DataMapper::Validations::Context
- DataMapper::Validations::ContextualValidators
- DataMapper::Validations::Format
- DataMapper::Validations::Format::Email
- DataMapper::Validations::Format::Url
- DataMapper::Validations::FormatValidator
- DataMapper::Validations::GenericValidator
- DataMapper::Validations::LengthValidator
- DataMapper::Validations::MethodValidator
- DataMapper::Validations::NumericalityValidator
- DataMapper::Validations::OrderedHash
- DataMapper::Validations::PresenceValidator
- DataMapper::Validations::PrimitiveTypeValidator
- DataMapper::Validations::UniquenessValidator
- DataMapper::Validations::UnknownValidationFormat
- DataMapper::Validations::ValidatesAbsence
- DataMapper::Validations::ValidatesAcceptance
- DataMapper::Validations::ValidatesConfirmation
- DataMapper::Validations::ValidatesFormat
- DataMapper::Validations::ValidatesLength
- DataMapper::Validations::ValidatesNumericality
- DataMapper::Validations::ValidatesPresence
- DataMapper::Validations::ValidatesPrimitiveType
- DataMapper::Validations::ValidatesUniqueness
- DataMapper::Validations::ValidatesWithBlock
- DataMapper::Validations::ValidatesWithMethod
- DataMapper::Validations::ValidatesWithin
- DataMapper::Validations::ValidationErrors
- DataMapper::Validations::WithinValidator
- Object

No matching classes.

# DataMapper::Validations::ValidatesPresence

### Public Instance Methods

validates_presence_of(*fields) click to toggle source

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_presence_of :required_attribute
      validates_presence_of :another_required, :yet_again

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

    # File lib/dm-validations/validators/required_field_validator.rb, line 76
    def validates_presence_of(*fields)
      validators.add(PresenceValidator, *fields)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.