# Validation on phone number

**URL:** <https://www.ruby-forum.com/t/validation-on-phone-number/244348>\
**Category:** Rails\
**Created:** [March 24, 2016, 10:48pm UTC](https://www.ruby-forum.com/t/validation-on-phone-number/244348 "2016-03-24T22:48:53Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [March 24, 2016, 10:48pm UTC](https://www.ruby-forum.com/t/validation-on-phone-number/244348/1 "2016-03-24T22:48:53Z")

</div>

Hi,  
i have column name phone with integer datatype but when i enter phone  
number it throws an error  
“1325565488 is out of range for ActiveRecord::Type::Integer with limit  
4”

i have changed limit to 8 in migration file but still it didn’t work.

Any kind suggestions would be appreciated. Thanks

---

<div class="post-metadata">

**Author:** ![guest0005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b5ac83/32.png) [@guest0005](https://www.ruby-forum.com/u/guest0005)\
**Post date:** [March 24, 2016, 10:52pm UTC](https://www.ruby-forum.com/t/validation-on-phone-number/244348/2 "2016-03-24T22:52:21Z")

</div>

Use a string.

–Rob  
Sent from my cell, please excuse any typos.

---

<div class="post-metadata">

**Author:** ![guest0005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b5ac83/32.png) [@guest0005](https://www.ruby-forum.com/u/guest0005)\
**Post date:** [March 24, 2016, 10:54pm UTC](https://www.ruby-forum.com/t/validation-on-phone-number/244348/3 "2016-03-24T22:54:57Z")

</div>

Use string where??? i’m just a beginner so can u tell me that in detail

---

<div class="post-metadata">

**Author:** ![guest0005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b5ac83/32.png) [@guest0005](https://www.ruby-forum.com/u/guest0005)\
**Post date:** [March 24, 2016, 11:00pm UTC](https://www.ruby-forum.com/t/validation-on-phone-number/244348/4 "2016-03-24T23:00:31Z")

</div>

On 24 March 2016 at 21:54, Ramu G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Use string where??? i’m just a beginner so can u tell me that in detail

As the datatype for the column in the database.

Colin

---

<div class="post-metadata">

**Author:** ![guest0005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b5ac83/32.png) [@guest0005](https://www.ruby-forum.com/u/guest0005)\
**Post date:** [March 24, 2016, 11:01pm UTC](https://www.ruby-forum.com/t/validation-on-phone-number/244348/5 "2016-03-24T23:01:07Z")

</div>

Use a string data type for the number.

–Rob  
Sent from my cell, please excuse any typos.

---

<div class="post-metadata">

**Author:** ![guest0005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b5ac83/32.png) [@guest0005](https://www.ruby-forum.com/u/guest0005)\
**Post date:** [March 26, 2016, 10:25am UTC](https://www.ruby-forum.com/t/validation-on-phone-number/244348/6 "2016-03-26T10:25:45Z")

</div>

Ramu G. wrote in post #1182441:

> Hi,  
> i have column name phone with integer datatype but when i enter phone  
> number it throws an error  
> “1325565488 is out of range for ActiveRecord::Type::Integer with limit  
> 4”

goto your db folder and in the migration change the phone number field  
data type from integer to string. and thats all. but u will will to do  
rake db:migrate  
after that.

---

<div class="post-metadata">

**Author:** ![guest0005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b5ac83/32.png) [@guest0005](https://www.ruby-forum.com/u/guest0005)\
**Post date:** [March 26, 2016, 10:37am UTC](https://www.ruby-forum.com/t/validation-on-phone-number/244348/7 "2016-03-26T10:37:55Z")

</div>

On 26 March 2016 at 09:25, Naveed A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> after that.  
> It is best to add a new migration to do this.

Colin

---

<div class="post-metadata">

**Author:** ![guest0005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b5ac83/32.png) [@guest0005](https://www.ruby-forum.com/u/guest0005)\
**Post date:** [March 27, 2016, 5:38am UTC](https://www.ruby-forum.com/t/validation-on-phone-number/244348/8 "2016-03-27T05:38:01Z")

</div>

On Sat, Mar 26, 2016 at 4:35 AM, Colin L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > rake db:migrate  
> > after that.
> 
> It is best to add a new migration to do this.
> 
> Colin

((this is what I tried to send))

Agreed. If you change an old migration, and run `rake db:migrate`  
_NOTHING_  
will happen, because that migration is already saved in the database  
table  
‘schema\_migrations’. You either need to create a new migration, or you  
have  
to drop the data base and re-run all the migrations.

I once tried to circumvent this in a panic situation by deleting the  
schema  
migration record and re-running the migration, but it was such a crazy  
thing to try, I gave up.

My advice is to do just as Colin suggested, and use a _new_ migration to  
change the table.

---

<div class="post-metadata">

**Author:** ![guest0005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b5ac83/32.png) [@guest0005](https://www.ruby-forum.com/u/guest0005)\
**Post date:** [March 27, 2016, 9:59am UTC](https://www.ruby-forum.com/t/validation-on-phone-number/244348/9 "2016-03-27T09:59:44Z")

</div>

On 26 March 2016 at 14:37, tamouse pontiki [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Sorry if this was duplicated – I was trying to use Apple Mail again after  
> all these years and suddenly remembered why I wasn’t using it.

Hi Tamouse, I don’t think we received it once, let alone twice. At  
least I did not see it.

Colin

---

<div class="post-metadata">

**Author:** ![guest0005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b5ac83/32.png) [@guest0005](https://www.ruby-forum.com/u/guest0005)\
**Post date:** [March 27, 2016, 9:41am UTC](https://www.ruby-forum.com/t/validation-on-phone-number/244348/10 "2016-03-27T09:41:03Z")

</div>

Sorry if this was duplicated – I was trying to use Apple Mail again  
after  
all these years and suddenly remembered why I wasn’t using it.

On Sat, Mar 26, 2016 at 9:34 AM, tamouse pontiki  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![guest0005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b5ac83/32.png) [@guest0005](https://www.ruby-forum.com/u/guest0005)\
**Post date:** [March 27, 2016, 1:56pm UTC](https://www.ruby-forum.com/t/validation-on-phone-number/244348/11 "2016-03-27T13:56:19Z")

</div>

> > > "1325565488 is out of range for ActiveRecord::Type::Integer with limit
> 
> ((this is what I tried to send))
> 
> Agreed. If you change an old migration, and run `rake db:migrate` _NOTHING_ will  
> happen, because that migration is already saved in the database table  
> ‘schema\_migrations’. You either need to create a new migration, or you have to  
> drop the data base and re-run all the migrations.
> 
> I once tried to circumvent this in a panic situation by deleting the schema  
> migration record and re-running the migration, but it was such a crazy thing to  
> try, I gave up.
> 
> My advice is to do just as Colin suggested, and use a _new_ migration to change  
> the table.

It’s helpful to think of migrations as “version control for your  
database”. They capture the steps along the way to where you are now  
(the schema.rb is the current state, or HEAD, of your migrations).

Walter

---

<div class="post-metadata">

**Author:** ![JasonMay](https://www.ruby-forum.com/user_avatar/www.ruby-forum.com/jasonmay/32/2643_2.png) [@JasonMay](https://www.ruby-forum.com/u/JasonMay)\
**Post date:** [December 28, 2020, 8:10pm UTC](https://www.ruby-forum.com/t/validation-on-phone-number/244348/12 "2020-12-28T20:10:27Z")

</div>

Thank u guys a lot! It helped me

---

<div class="post-metadata">

**Author:** ![JasonMay](https://www.ruby-forum.com/user_avatar/www.ruby-forum.com/jasonmay/32/2643_2.png) [@JasonMay](https://www.ruby-forum.com/u/JasonMay)\
**Post date:** [January 6, 2021, 8:41pm UTC](https://www.ruby-forum.com/t/validation-on-phone-number/244348/13 "2021-01-06T20:41:00Z")

</div>

I had similar kind of problems, but unfortunately nothing helped me. I even wrote on the forums and did not find the correct answer for this. But I also had such a problem that I wanted to create accounts on some sites, but I needed a confirmation with a mobile number, and I did not want to show my mobile phone to different sites, because I am doing business. So I decided to google what to do in this situation and came across [VerifyWithSMS](https://verifywithsms.com/) . And now, using this service, I create any accounts on any sites without a mobile number 🙂
