motion/validatable.rb
def validate_length(field, value, setting)
      if value.is_a?(String) || value.nil?
        result = value.nil? || (value.length < setting.first || value.length > setting.last)
        add_message(field, "incorrect value supplied for #{field.to_s} -- should be between #{setting.first} and #{setting.last} characters long.") if result
        return !result
      end
      return false
    end
def validate_length(field, value, setting)
      if value.is_a?(String) || value.nil?
        result = value.nil? || (value.length < setting.first || value.length > setting.last)
        add_message(field, "incorrect value supplied for #{field.to_s} -- should be between #{setting.first} and #{setting.last} characters long.") if result
        return !result
      end
      return false
    end
Validates that the length is in a given range of characters. E.g.,

     validate :name,   :length => 5..8