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 Development With Rails, 2nd Ed. p.369 ####

validates_length_of

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.

## EXAMPLES ##

validates_length_of :name, :maximum => 50 validates_length_of :password, :in => 6..20 validates_length_of :address, :minimum => 10, :message => "seems too short" end

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

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

def validate

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

end

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

I must not have read his post carefully enough.

Thanks. this helps =]