Re: Custom validations in rails: validates_number_range

Matt Sir
Sun, 24 Jun 2007 19:33:41 -0000

If I understood what you are trying to do correctly
validates_length_of :user_name, :within => 6..20, :too_long => "pick
a
shorter name", :too_short => "pick a longer name"

from
http://railsmanual.com/module/ActiveRecord::Validations::ClassMethods/validates_length_of/1.1.2

Matt

Ye Dingding wrote:
> http://sishen.lifegoo.com/?p=42
>
> I don''t know whether there exists a builtin validation that can
check
> the
> number range. I think the requirement is normal, but indeed, i
can''t
> find
> it.  So i wrote a custome validation: validates_number_range, whose
> prototype is validates_length_of. If there already exists one, pls tell
> me,
> :)
>

--
Posted via http://www.ruby-forum.com/.