Validates_amount .. is there any?

Is there any plugin which validates amount?? say the amount entered
should be greater than 0.

Thanks =]

Taken From Agile Web D. With Rails, 2nd Ed. p.369


Validates that the length of the value of each of the attributes meets
some constraint:
at least a given length, at most a given length, between two lengths,
or exactly a given
length. Rather than having a single :message option, this validator
allows separate mes-
sages for dif ferent validation failures, although :message may still
be used. In all options,
the lengths may not be negative.


validates_length_of :name, :maximum => 50
validates_length_of :password, :in => 6…20
validates_length_of :address, :minimum => 10,
:message => “seems too short”

validates_lenght_of is meant for strings, it can behave unexpected
when used on integer attributes as it uses byte comparison …

I must not have read his post carefully enough.

This is covered in the agile book. You need to write your own

def validate
errors.add :price, “must be greater than 0” unless self.price > 0

That’s a quickie off the top of my head. You may want to only do that
if the value is filled in (self.price.blank?). That’s up to you.

Thanks. this helps =]

Go look at the online Rails docs, and click on “Show source” for the
validates_blah functions. They are pretty straightforward.