Module: DataMapper::Validate::ValidatesLength

Module | DataMapper::Validate::ValidatesLength
In: | lib/dm-validations/length_validator.rb

### Methods

validates_length

### Public Instance methods

validates_length(*fields)

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 :allow_nil<Boolean> true/false (default is true) @option :minimum ensures that the attribute‘s length is greater than

      or equal to the supplied value

@option :min alias for :minimum @option :maximum ensures the attribute‘s length is less than or equal

      to the supplied value

@option :max alias for :maximum @option :equals ensures the attribute‘s length is equal to the

      supplied value

@option :is alias for :equals @option :in<Range> given a Range, ensures that the attributes length is

      include?'ed in the Range

@option :within<Range> 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 :high, :min => 100000000000
        validates_length :low, :equals => 0
        validates_length :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)

[Validate]