From 5b4025b76be410a8e064dc64e9bc1a04bd171770 Mon Sep 17 00:00:00 2001 From: Evan Brodie Date: Tue, 24 Mar 2020 17:24:20 -0400 Subject: [PATCH] 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. --- guides/source/active_record_validations.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/guides/source/active_record_validations.md b/guides/source/active_record_validations.md index 992d639e69..16d9b3b51e 100644 --- a/guides/source/active_record_validations.md +++ b/guides/source/active_record_validations.md @@ -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`