1
0
Fork 0
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:
Evan Brodie 2020-03-24 17:24:20 -04:00 committed by Evan Brodie
parent 4d0c335cbb
commit 5b4025b76b

View file

@ -477,10 +477,10 @@ personalized message or call `presence` prior to `length`.
This helper validates that your attributes have only numeric values. By
default, it will match an optional sign followed by an integral or floating
point number. To specify that only integral numbers are allowed set
`:only_integer` to true.
point number.
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
/\A[+-]?\d+\z/
@ -496,6 +496,8 @@ class Player < ApplicationRecord
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
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.
The default error message is _"is not a number"_.
The default error message when no options are specified is _"is not a number"_.
### `presence`