Module: DataMapper::Validations::ValidatesLength

### Home Classes Methods

### In Files

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

### Methods

- #validates_length_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::ValidatesLength

### Public Instance Methods

validates_length_of(*fields) click to toggle source

Validates that the length of the attribute is equal to, less than, greater than or within a certain range (depending upon the options you specify).

@option [Boolean] :allow_nil (true)

    true or false.

@option [Boolean] :allow_blank (true)

    true or false.

@option [Boolean] :minimum

    Ensures that the attribute's length is greater than or equal to
    the supplied value.

@option [Boolean] :min

    Alias for :minimum.

@option [Boolean] :maximum

    Ensures the attribute's length is less than or equal to the
    supplied value.

@option [Boolean] :max

    Alias for :maximum.

@option [Boolean] :equals

    Ensures the attribute's length is equal to the supplied value.

@option [Boolean] :is

    Alias for :equals.

@option [Range] :in

    Given a Range, ensures that the attributes length is include?'ed
    in the Range.

@option [Range] :within

    Alias for :in.

@example Usage

    require 'dm-validations'

    class Page
      include DataMapper::Resource

      property high, Integer
      property low, Integer
      property just_right, Integer

      validates_length_of :high, :min => 100000000000
      validates_length_of :low, :equals => 0
      validates_length_of :just_right, :within => 1..10

      # a call to valid? will return false unless:
      # high is greater than or equal to 100000000000
      # low is equal to 0
      # just_right is between 1 and 10 (inclusive of both 1 and 10)

    # File lib/dm-validations/validators/length_validator.rb, line 242
    def validates_length_of(*fields)
      validators.add(LengthValidator, *fields)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.