gbdev / validates_as_phone_number

Rails gem to validate U.S. phone numbers

This URL has Read+Write access

name age message
file CHANGELOG Fri Aug 15 15:41:20 -0700 2008 updated version. moved from spovich to gbdev. [John Dell]
file LICENSE Fri Aug 15 13:20:00 -0700 2008 updated readme [John Dell]
file README Tue Jan 27 12:00:23 -0800 2009 bump revision, merge pivotal authors, and reset... [spovich]
file Rakefile Fri Aug 15 13:15:10 -0700 2008 initial checkin [John Dell]
file init.rb Fri Aug 15 13:15:10 -0700 2008 initial checkin [John Dell]
directory lib/ Tue Jan 27 11:44:59 -0800 2009 js/bk - allow optional space after x for extens... [pivotal]
directory test/ Tue Jan 27 11:44:59 -0800 2009 js/bk - allow optional space after x for extens... [pivotal]
file validates_as_phone_number.gemspec Tue Jan 27 12:00:23 -0800 2009 bump revision, merge pivotal authors, and reset... [spovich]
README
ValidatesAsPhoneNumber
======================

This Ruby on Rails plugin/gem implements an ActiveRecord validation helper called
validates_as_phone_number which validates U.S. phone numbers. The helper acts as
if validates_format_of was used with a regular expression that defines:

(000) 000 0000
(000) 000-0000
000.000.0000
000-000-0000
000-0000
000-000-0000x000 (extension can be up to 7 digits)
000-000-0000 x1234567 (extension can be up to 7 digits with or without leading space before 'x')
000-0000x000 (extension can be up to 7 digits)


Installation:
=============
gem sources -a http://gems.github.com

Install the gem(s):
sudo gem install gbdev-validates_as_phone_number

Add to environment.rb initializer block:
config.gem 'gbdev-validates_as_phone_number', :version => '>=0.7.5', :lib => 'validates_as_phone_number', :source => 
'http://gems.github.com'


Usage:
======
In your model file do something like:

class MyClass < ActiveRecord::Base
  validates_as_phone_number :work_phone, :message => 'Invalid work phone number format', :allow_nil => true
end

Tests:
======
Some tests have been added.

License:
========
See the LICENSE file.