提交 bc71e432 编写于 作者: R Robin Dupret

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]
上级 1099e54b
......@@ -99,7 +99,8 @@ def skip_nil_check?(key)
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 HelperMethods
# 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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册