From 5affa79f2a5fe73e4bf9ddf1bd2abdfa5667361b Mon Sep 17 00:00:00 2001 From: CassioMarques Date: Mon, 10 Nov 2008 19:15:40 -0200 Subject: Added documentation for validates_numericallity_of --- .../html/activerecord_validations_callbacks.html | 21 ++++++++++++++------- .../source/activerecord_validations_callbacks.txt | 19 ++++++++++++++----- 2 files changed, 28 insertions(+), 12 deletions(-) (limited to 'railties') diff --git a/railties/doc/guides/html/activerecord_validations_callbacks.html b/railties/doc/guides/html/activerecord_validations_callbacks.html index c82f428985..6feaae68ea 100644 --- a/railties/doc/guides/html/activerecord_validations_callbacks.html +++ b/railties/doc/guides/html/activerecord_validations_callbacks.html @@ -245,9 +245,6 @@ ul#navMain { Common validation options
  • - Credits -
  • -
  • Changelog
  • @@ -528,6 +525,19 @@ http://www.gnu.org/software/src-highlite --> end

    3.9. The validates_numericallity_of helper

    +

    This helper validates that your attributes have only numeric values. By default, it will match an optional sign followed by a integral or floating point number. Using the :integer_only option set to true, you can specify that only integral numbers are allowed.

    +

    If you use :integer_only set to true, then it will use the /\A[+\-]?\d+\Z/ regular expression to validate the attribute's value. Otherwise, it will try to convert the value using Kernel.Float.

    +
    +
    +
    class Player < ActiveRecord::Base
    +  validates_numericallity_of :points
    +  validates_numericallity_of :games_played, :integer_only => true
    +end
    +
    +

    The default error message for validates_numericallity_of is "is not a number".

    3.10. The validates_presence_of helper

    3.11. The validates_size_of helper

    3.12. The validates_uniqueness_of+ helper

    @@ -535,10 +545,7 @@ http://www.gnu.org/software/src-highlite -->

    4. Common validation options

    -

    5. Credits

    -
    -
    -

    6. Changelog

    +

    5. Changelog

    diff --git a/railties/doc/guides/source/activerecord_validations_callbacks.txt b/railties/doc/guides/source/activerecord_validations_callbacks.txt index af82f62b6b..b26ebfed41 100644 --- a/railties/doc/guides/source/activerecord_validations_callbacks.txt +++ b/railties/doc/guides/source/activerecord_validations_callbacks.txt @@ -221,18 +221,27 @@ end === The +validates_numericallity_of+ helper -=== The +validates_presence_of+ helper +This helper validates that your attributes have only numeric values. By default, it will match an optional sign followed by a integral or floating point number. Using the +:integer_only+ option set to true, you can specify that only integral numbers are allowed. -=== The +validates_size_of+ helper +If you use +:integer_only+ set to +true+, then it will use the +$$/\A[+\-]?\d+\Z/$$+ regular expression to validate the attribute's value. Otherwise, it will try to convert the value using +Kernel.Float+. -=== The validates_uniqueness_of+ helper +[source, ruby] +------------------------------------------------------------------ +class Player < ActiveRecord::Base + validates_numericallity_of :points + validates_numericallity_of :games_played, :integer_only => true +end +------------------------------------------------------------------ -== Common validation options +The default error message for +validates_numericallity_of+ is "_is not a number_". +=== The +validates_presence_of+ helper +=== The +validates_size_of+ helper -== Credits +=== The validates_uniqueness_of+ helper +== Common validation options == Changelog -- cgit v1.2.3