mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #25315 from schneems/schneems/inclusion-doc
[ci skip] Expand information on message options
This commit is contained in:
commit
154f11663e
1 changed files with 9 additions and 3 deletions
|
@ -392,7 +392,8 @@ The `exclusion` helper has an option `:in` that receives the set of values that
|
|||
will not be accepted for the validated attributes. The `:in` option has an
|
||||
alias called `:within` that you can use for the same purpose, if you'd like to.
|
||||
This example uses the `:message` option to show how you can include the
|
||||
attribute's value.
|
||||
attribute's value. For full options to the message argument please see the
|
||||
[message documentation](#message).
|
||||
|
||||
The default error message is _"is reserved"_.
|
||||
|
||||
|
@ -427,7 +428,8 @@ end
|
|||
The `inclusion` helper has an option `:in` that receives the set of values that
|
||||
will be accepted. The `:in` option has an alias called `:within` that you can
|
||||
use for the same purpose, if you'd like to. The previous example uses the
|
||||
`:message` option to show how you can include the attribute's value.
|
||||
`:message` option to show how you can include the attribute's value. For full
|
||||
options please see the [message documentation](#message).
|
||||
|
||||
The default error message for this helper is _"is not included in the list"_.
|
||||
|
||||
|
@ -768,6 +770,9 @@ class Coffee < ApplicationRecord
|
|||
end
|
||||
```
|
||||
|
||||
For full options to the message argument please see the
|
||||
[message documentation](#message).
|
||||
|
||||
### `:allow_blank`
|
||||
|
||||
The `:allow_blank` option is similar to the `:allow_nil` option. This option
|
||||
|
@ -792,7 +797,8 @@ for each validation helper. The `:message` option accepts a `String` or `Proc`.
|
|||
|
||||
A `String` `:message` value can optionally contain any/all of `%{value}`,
|
||||
`%{attribute}`, and `%{model}` which will be dynamically replaced when
|
||||
validation fails.
|
||||
validation fails. This replacement is done using the I18n gem, and the
|
||||
placeholders must match exactly, no spaces are allowed.
|
||||
|
||||
A `Proc` `:message` value is given two arguments: the object being validated, and
|
||||
a hash with `:model`, `:attribute`, and `:value` key-value pairs.
|
||||
|
|
Loading…
Reference in a new issue