Module: DataMapper::Validations::ValidatesAcceptance

### Home Classes Methods

### In Files

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

### Methods

- #validates_acceptance_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::ValidatesAcceptance

### Public Instance Methods

validates_acceptance_of(*fields) click to toggle source

Validates that the attributes's value is in the set of accepted values.

@option [Boolean] :allow_nil (true)

    true if nil is allowed, false if not allowed.

@option [Array] :accept (["1", 1, "true", true, "t"])

    A list of accepted values.

@example Usage

    require 'dm-validations'

    class Page
      include DataMapper::Resource

      property :license_agreement_accepted, String
      property :terms_accepted, String
      validates_acceptance_of :license_agreement, :accept => "1"
      validates_acceptance_of :terms_accepted, :allow_nil => false

      # a call to valid? will return false unless:
      # license_agreement is nil or "1"
      # and
      # terms_accepted is one of ["1", 1, "true", true, "t"]

    # File lib/dm-validations/validators/acceptance_validator.rb, line 71
    def validates_acceptance_of(*fields)
      validators.add(AcceptanceValidator, *fields)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.