mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Adds default message for :only_integer validation
This adds consistency to the documentation because all other options to the `:numericality` validator have their default error messages mentioned.
This commit is contained in:
parent
4d0c335cbb
commit
5b4025b76b
1 changed files with 6 additions and 4 deletions
|
@ -477,10 +477,10 @@ personalized message or call `presence` prior to `length`.
|
||||||
|
|
||||||
This helper validates that your attributes have only numeric values. By
|
This helper validates that your attributes have only numeric values. By
|
||||||
default, it will match an optional sign followed by an integral or floating
|
default, it will match an optional sign followed by an integral or floating
|
||||||
point number. To specify that only integral numbers are allowed set
|
point number.
|
||||||
`:only_integer` to true.
|
|
||||||
|
|
||||||
If you set `:only_integer` to `true`, then it will use the
|
To specify that only integral numbers are allowed,
|
||||||
|
set `:only_integer` to true. Then it will use the
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
/\A[+-]?\d+\z/
|
/\A[+-]?\d+\z/
|
||||||
|
@ -496,6 +496,8 @@ class Player < ApplicationRecord
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The default error message for `:only_integer` is _"must be an integer"_.
|
||||||
|
|
||||||
Besides `:only_integer`, this helper also accepts the following options to add
|
Besides `:only_integer`, this helper also accepts the following options to add
|
||||||
constraints to acceptable values:
|
constraints to acceptable values:
|
||||||
|
|
||||||
|
@ -521,7 +523,7 @@ constraints to acceptable values:
|
||||||
|
|
||||||
NOTE: By default, `numericality` doesn't allow `nil` values. You can use `allow_nil: true` option to permit it.
|
NOTE: By default, `numericality` doesn't allow `nil` values. You can use `allow_nil: true` option to permit it.
|
||||||
|
|
||||||
The default error message is _"is not a number"_.
|
The default error message when no options are specified is _"is not a number"_.
|
||||||
|
|
||||||
### `presence`
|
### `presence`
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue