From e9e9ed6b60a42a7c3afe3c4a9f8cf6d1e5422e59 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Sat, 5 Feb 2011 16:33:00 -0800 Subject: Be able to pass a validator method to #validates --- activemodel/lib/active_model/validations/with.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'activemodel/lib/active_model') diff --git a/activemodel/lib/active_model/validations/with.rb b/activemodel/lib/active_model/validations/with.rb index 200efd4eb5..16d81263a2 100644 --- a/activemodel/lib/active_model/validations/with.rb +++ b/activemodel/lib/active_model/validations/with.rb @@ -8,6 +8,12 @@ module ActiveModel end end + class WithValidator < EachValidator + def validate_each(record, attr, val) + record.send options[:with] + end + end + module ClassMethods # Passes the record off to the class or classes specified and allows them # to add errors based on more complex conditions. -- cgit v1.2.3