1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #38812 from ecbrodie/ecbrodie-patch-validations-docs

Adds default message for :only_integer validation
This commit is contained in:
Eugene Kenny 2020-03-25 02:16:43 +00:00 committed by GitHub
commit e2cf0b1d78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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`