Forum: Ruby on Rails Validate Length

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7492b14ddb61f186cdb44843ac5a3ac1?d=identicon&s=25 doucie (Guest)
on 2007-02-12 21:59
I'm trying to validate that someone enters an 8 digit number exactly.
I'm using the following line but it does not seem to work.  Can anyone
help?

validates_length_of :debt_ref, :is =>8, :message =>"- The debtref can
only be 8 digits long"
C4dc94c893471878a105761a9207f29b?d=identicon&s=25 Zack Chandler (Guest)
on 2007-02-12 22:11
(Received via mailing list)
On 2/12/07, doucie <rails-mailing-list@andreas-s.net> wrote:
>
> I'm trying to validate that someone enters an 8 digit number exactly.
> I'm using the following line but it does not seem to work.  Can anyone
> help?
>
> validates_length_of :debt_ref, :is =>8, :message =>"- The debtref can
> only be 8 digits long"
>

Your syntax looks right - what is the error that you're seeing?

--
Zack Chandler
http://depixelate.com
7492b14ddb61f186cdb44843ac5a3ac1?d=identicon&s=25 doucie (Guest)
on 2007-02-12 22:17
Zack Chandler wrote:
> On 2/12/07, doucie <rails-mailing-list@andreas-s.net> wrote:
>>
>> I'm trying to validate that someone enters an 8 digit number exactly.
>> I'm using the following line but it does not seem to work.  Can anyone
>> help?
>>
>> validates_length_of :debt_ref, :is =>8, :message =>"- The debtref can
>> only be 8 digits long"
>>
>
> Your syntax looks right - what is the error that you're seeing?
>
> --
> Zack Chandler
> http://depixelate.com

There is no error, the model just accepts a number greater than 8
digits!
This topic is locked and can not be replied to.