aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/validations/clusivity.rb10
-rw-r--r--activemodel/lib/active_model/validations/exclusion.rb1
-rw-r--r--activemodel/lib/active_model/validations/inclusion.rb1
3 files changed, 7 insertions, 5 deletions
diff --git a/activemodel/lib/active_model/validations/clusivity.rb b/activemodel/lib/active_model/validations/clusivity.rb
index 7f88293220..643a6f2b7c 100644
--- a/activemodel/lib/active_model/validations/clusivity.rb
+++ b/activemodel/lib/active_model/validations/clusivity.rb
@@ -4,10 +4,10 @@ module ActiveModel
module Validations
module Clusivity #:nodoc:
ERROR_MESSAGE = "An object with the method #include? or a proc or lambda is required, " <<
- "and must be supplied as the :in option of the configuration hash"
+ "and must be supplied as the :in (or :within) option of the configuration hash"
def check_validity!
- unless [:include?, :call].any?{ |method| range.respond_to?(method) }
+ unless [:include?, :call].any?{ |method| delimiter.respond_to?(method) }
raise ArgumentError, ERROR_MESSAGE
end
end
@@ -15,12 +15,12 @@ module ActiveModel
private
def include?(record, value)
- exclusions = range.respond_to?(:call) ? range.call(record) : range
+ exclusions = delimiter.respond_to?(:call) ? delimiter.call(record) : delimiter
exclusions.send(inclusion_method(exclusions), value)
end
- def range
- @range ||= options[:in] || options[:within]
+ def delimiter
+ @delimiter ||= options[:in] || options[:within]
end
# In Ruby 1.9 <tt>Range#include?</tt> on non-numeric ranges checks all possible values in the
diff --git a/activemodel/lib/active_model/validations/exclusion.rb b/activemodel/lib/active_model/validations/exclusion.rb
index dfeec37ca1..dc3368c569 100644
--- a/activemodel/lib/active_model/validations/exclusion.rb
+++ b/activemodel/lib/active_model/validations/exclusion.rb
@@ -30,6 +30,7 @@ module ActiveModel
# * <tt>:in</tt> - An enumerable object of items that the value shouldn't
# be part of. This can be supplied as a proc or lambda which returns an
# enumerable. If the enumerable is a range the test is performed with
+ # * <tt>:within</tt> - A synonym(or alias) for <tt>:in</tt>
# <tt>Range#cover?</tt>, otherwise with <tt>include?</tt>.
# * <tt>:message</tt> - Specifies a custom error message (default is: "is
# reserved").
diff --git a/activemodel/lib/active_model/validations/inclusion.rb b/activemodel/lib/active_model/validations/inclusion.rb
index 5a679e0423..c2835c550b 100644
--- a/activemodel/lib/active_model/validations/inclusion.rb
+++ b/activemodel/lib/active_model/validations/inclusion.rb
@@ -30,6 +30,7 @@ module ActiveModel
# supplied as a proc or lambda which returns an enumerable. If the
# enumerable is a range the test is performed with <tt>Range#cover?</tt>,
# otherwise with <tt>include?</tt>.
+ # * <tt>:within</tt> - A synonym(or alias) for <tt>:in</tt>
# * <tt>:message</tt> - Specifies a custom error message (default is: "is
# not included in the list").
# * <tt>:allow_nil</tt> - If set to +true+, skips this validation if the