aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
authorRobin Dupret <robin.dupret@gmail.com>2015-07-01 16:20:07 +0200
committerRobin Dupret <robin.dupret@gmail.com>2015-07-01 16:20:07 +0200
commitbc71e43252c49e990dbe22ee0cb3c017a6026d04 (patch)
treebef509cc4069b5452f92dffe1db29a9652296485 /activemodel
parent1099e54b497ec3ec08d8913f8a899681719a0e4b (diff)
downloadrails-bc71e43252c49e990dbe22ee0cb3c017a6026d04.tar.gz
rails-bc71e43252c49e990dbe22ee0cb3c017a6026d04.tar.bz2
rails-bc71e43252c49e990dbe22ee0cb3c017a6026d04.zip
Separate the constraint and other options [ci skip]
Only one constraint option can be used at a time (except for the minimum and maximum ones that can eventually be combined). However, other options can be used with them (e.g. the validation failure message). So let's make the distinction between these two different options categories. [Yves Senn, Matthew Draper & Robin Dupret]
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/lib/active_model/validations/length.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/activemodel/lib/active_model/validations/length.rb b/activemodel/lib/active_model/validations/length.rb
index fb33342d30..910cca2f49 100644
--- a/activemodel/lib/active_model/validations/length.rb
+++ b/activemodel/lib/active_model/validations/length.rb
@@ -99,7 +99,8 @@ module ActiveModel
module HelperMethods
# Validates that the specified attributes match the length restrictions
- # supplied. Only one option can be used at a time:
+ # supplied. Only one constraint option can be used at a time apart from
+ # +:minimum+ and +:maximum+ that can be combined together:
#
# class Person < ActiveRecord::Base
# validates_length_of :first_name, maximum: 30
@@ -118,14 +119,18 @@ module ActiveModel
# end
# end
#
- # Configuration options:
+ # Constraint options:
+ #
# * <tt>:minimum</tt> - The minimum size of the attribute.
# * <tt>:maximum</tt> - The maximum size of the attribute. Allows +nil+ by
- # default if not used with :minimum.
+ # default if not used with +:minimum+.
# * <tt>:is</tt> - The exact size of the attribute.
# * <tt>:within</tt> - A range specifying the minimum and maximum size of
# the attribute.
# * <tt>:in</tt> - A synonym (or alias) for <tt>:within</tt>.
+ #
+ # Other options:
+ #
# * <tt>:allow_nil</tt> - Attribute may be +nil+; skip validation.
# * <tt>:allow_blank</tt> - Attribute may be blank; skip validation.
# * <tt>:too_long</tt> - The error message if the attribute goes over the