From bc71e43252c49e990dbe22ee0cb3c017a6026d04 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Wed, 1 Jul 2015 16:20:07 +0200 Subject: 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] --- activemodel/lib/active_model/validations/length.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'activemodel/lib') 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: + # # * :minimum - The minimum size of the attribute. # * :maximum - The maximum size of the attribute. Allows +nil+ by - # default if not used with :minimum. + # default if not used with +:minimum+. # * :is - The exact size of the attribute. # * :within - A range specifying the minimum and maximum size of # the attribute. # * :in - A synonym (or alias) for :within. + # + # Other options: + # # * :allow_nil - Attribute may be +nil+; skip validation. # * :allow_blank - Attribute may be blank; skip validation. # * :too_long - The error message if the attribute goes over the -- cgit v1.2.3