aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-12-06 00:41:05 -0800
committerJosé Valim <jose.valim@gmail.com>2011-12-06 00:41:05 -0800
commit1ee832b2d8bd64f8758f838c43854b3133831f1a (patch)
treefa0e5fc25497f0609d3fbd74ed6f2c11c1d0e103 /activemodel/lib/active_model
parenta2f7c1dc67b4cfd31d2b7840063b620ac1320d90 (diff)
parent5ff71ac9f844f2c8bcde8cdd5de767c9bdd4cc9e (diff)
downloadrails-1ee832b2d8bd64f8758f838c43854b3133831f1a.tar.gz
rails-1ee832b2d8bd64f8758f838c43854b3133831f1a.tar.bz2
rails-1ee832b2d8bd64f8758f838c43854b3133831f1a.zip
Merge pull request #3873 from iangreenleaf/no_default_tokenizer
Don't tokenize string when counting characters
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r--activemodel/lib/active_model/validations/length.rb3
1 files changed, 1 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/validations/length.rb b/activemodel/lib/active_model/validations/length.rb
index 6bc928bab7..95a8ca49e9 100644
--- a/activemodel/lib/active_model/validations/length.rb
+++ b/activemodel/lib/active_model/validations/length.rb
@@ -6,7 +6,6 @@ module ActiveModel
MESSAGES = { :is => :wrong_length, :minimum => :too_short, :maximum => :too_long }.freeze
CHECKS = { :is => :==, :minimum => :>=, :maximum => :<= }.freeze
- DEFAULT_TOKENIZER = lambda { |value| value.split(//) }
RESERVED_OPTIONS = [:minimum, :maximum, :within, :is, :tokenizer, :too_short, :too_long]
def initialize(options)
@@ -36,7 +35,7 @@ module ActiveModel
end
def validate_each(record, attribute, value)
- value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) if value.kind_of?(String)
+ value = options[:tokenizer].call(value) if value.kind_of?(String) && options[:tokenizer].present?
CHECKS.each do |key, validity_check|
next unless check_value = options[key]