# Validates\_numericality\_of and greater\_than\* doesn't appear to be working

**URL:** <https://www.ruby-forum.com/t/validates-numericality-of-and-greater-than-doesnt-appear-to-be-working/137285>\
**Category:** Rails\
**Created:** [May 11, 2008, 11:54am UTC](https://www.ruby-forum.com/t/validates-numericality-of-and-greater-than-doesnt-appear-to-be-working/137285 "2008-05-11T11:54:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ccuilla](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/77aa72/32.png) [@ccuilla](https://www.ruby-forum.com/u/ccuilla)\
**Post date:** [May 11, 2008, 11:54am UTC](https://www.ruby-forum.com/t/validates-numericality-of-and-greater-than-doesnt-appear-to-be-working/137285/1 "2008-05-11T11:54:40Z")

</div>

I’m using Rails 2.0.2 and I have been trying to take advantage of the  
“validates\_numericality\_of” with the “:greater\_than” option with  
something like this:

validates\_numericality\_of :users, :greater\_than =\> 0, :only\_integer =\>  
true, :allow\_nil =\> true, :message =\> “The number of allowed users  
must be a whole number greater than zero.”

But this doesn’t seem to be catching values set to zero or negative  
values.

Am I using this correctly?

NOTE: I have the same problem with the “” option so I assume it is  
something generally I’m doing wrong.

validates\_numericality\_of :value, :greater\_than\_or\_equal\_to =\>  
0, :only\_integer =\> true, :allow\_nil =\> true, :message =\> “Cannot use  
a negative or fractional number.”
