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.
doucie (Guest)
on 2007-02-12 22: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"
Zack C. (Guest)
on 2007-02-12 23:11
(Received via mailing list)
On 2/12/07, doucie <removed_email_address@domain.invalid> 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 C.
http://depixelate.com
doucie (Guest)
on 2007-02-12 23:17
Zack C. wrote:
> On 2/12/07, doucie <removed_email_address@domain.invalid> 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 C.
> 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.