aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/validations
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-12-23 01:37:19 +0100
committerJosé Valim <jose.valim@gmail.com>2009-12-23 01:38:15 +0100
commit279067639f319f3b4bbcaf90c26f286e96df2c77 (patch)
tree84ea6824ddc154c526d6d1094f20904cc5a25c81 /activemodel/lib/active_model/validations
parent977a5c43b160d8aa8d1b87bb0feb54db85fe203c (diff)
downloadrails-279067639f319f3b4bbcaf90c26f286e96df2c77.tar.gz
rails-279067639f319f3b4bbcaf90c26f286e96df2c77.tar.bz2
rails-279067639f319f3b4bbcaf90c26f286e96df2c77.zip
validates_each uses a BlockValidator.
Diffstat (limited to 'activemodel/lib/active_model/validations')
-rw-r--r--activemodel/lib/active_model/validations/length.rb7
-rw-r--r--activemodel/lib/active_model/validations/with.rb4
2 files changed, 5 insertions, 6 deletions
diff --git a/activemodel/lib/active_model/validations/length.rb b/activemodel/lib/active_model/validations/length.rb
index 1214c5f4bf..04280b401b 100644
--- a/activemodel/lib/active_model/validations/length.rb
+++ b/activemodel/lib/active_model/validations/length.rb
@@ -10,8 +10,8 @@ module ActiveModel
def initialize(options)
options[:tokenizer] ||= DEFAULT_TOKENIZER
- super
@type = (OPTIONS & options.keys).first
+ super
end
def check_validity!
@@ -108,9 +108,8 @@ module ActiveModel
# count words as in above example.)
# Defaults to <tt>lambda{ |value| value.split(//) }</tt> which counts individual characters.
def validates_length_of(*attr_names)
- options = { :tokenizer => DEFAULT_TOKENIZER }
- options.update(attr_names.extract_options!)
- validates_with LengthValidator, options.merge(:attributes => attr_names, :type => type)
+ options = attr_names.extract_options!
+ validates_with LengthValidator, options.merge(:attributes => attr_names)
end
alias_method :validates_size_of, :validates_length_of
diff --git a/activemodel/lib/active_model/validations/with.rb b/activemodel/lib/active_model/validations/with.rb
index 626e9d5731..8d521173c6 100644
--- a/activemodel/lib/active_model/validations/with.rb
+++ b/activemodel/lib/active_model/validations/with.rb
@@ -48,9 +48,9 @@ module ActiveModel
# end
# end
#
- def validates_with(*args)
+ def validates_with(*args, &block)
options = args.extract_options!
- args.each { |klass| validate(klass.new(options), options) }
+ args.each { |klass| validate(klass.new(options, &block), options) }
end
end
end