# Validates\_format\_of :phone,

**URL:** <https://www.ruby-forum.com/t/validates-format-of-phone/181786>\
**Category:** Rails\
**Created:** [January 18, 2010, 8:20am UTC](https://www.ruby-forum.com/t/validates-format-of-phone/181786 "2010-01-18T08:20:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4bbf92/32.png) [@ashu](https://www.ruby-forum.com/u/ashu)\
**Post date:** [January 18, 2010, 8:20am UTC](https://www.ruby-forum.com/t/validates-format-of-phone/181786/1 "2010-01-18T08:20:31Z")

</div>

validates\_format\_of :phone,  
:with =\> /\A\s\*(?:(?:+?(?:\d{1,3}(?:\s\*|[-.])))?(?\d{3}[-/)]?\s\*)  
(?:[2-9][0-9 -.]{6,})\s\*\z/,

i pit it on my reuriments but error whlie entering  
666.111.9999  
i want it should be ok  
any one help me please

---

<div class="post-metadata">

**Author:** ![ashu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4bbf92/32.png) [@ashu](https://www.ruby-forum.com/u/ashu)\
**Post date:** [January 18, 2010, 1:03pm UTC](https://www.ruby-forum.com/t/validates-format-of-phone/181786/2 "2010-01-18T13:03:55Z")

</div>

ashu wrote:

> validates\_format\_of :phone,  
> :with =\> /\A\s\*(?:(?:+?(?:\d{1,3}(?:\s\*|[-.])))?(?\d{3}[-/)]?\s\*)  
> (?:[2-9][0-9 -.]{6,})\s\*\z/,
> 
> i pit it on my reuriments but error whlie entering  
> 666.111.9999  
> i want it should be ok  
> any one help me please

Please post a set of valid and a set of invalid numbers.

T.

---

<div class="post-metadata">

**Author:** ![ashu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4bbf92/32.png) [@ashu](https://www.ruby-forum.com/u/ashu)\
**Post date:** [January 18, 2010, 5:16pm UTC](https://www.ruby-forum.com/t/validates-format-of-phone/181786/3 "2010-01-18T17:16:49Z")

</div>

ashu wrote:

> validates\_format\_of :phone,  
> :with =\> /\A\s\*(?:(?:+?(?:\d{1,3}(?:\s\*|[-.])))?(?\d{3}[-/)]?\s\*)  
> (?:[2-9][0-9 -.]{6,})\s\*\z/,
> 
> i pit it on my reuriments but error whlie entering  
> 666.111.9999  
> i want it should be ok  
> any one help me please

Don’t do that. Your app should be smart enough not to care about the  
format of phone numbers.

Best,  
–Â  
Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![ashu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4bbf92/32.png) [@ashu](https://www.ruby-forum.com/u/ashu)\
**Post date:** [January 19, 2010, 8:45am UTC](https://www.ruby-forum.com/t/validates-format-of-phone/181786/4 "2010-01-19T08:45:40Z")

</div>

i have done it myself in very well manner  
thanxxx

On Mon, Jan 18, 2010 at 9:46 PM, Marnen Laibow-Koser
