Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Rails gem to validate U.S. phone numbers
Ruby
tree: f5031d3640
Failed to load latest commit information.
lib js/bk - allow optional space after x for extension to play well with …
test js/bk - allow optional space after x for extension to play well with …
CHANGELOG
LICENSE updated readme
README bump revision, merge pivotal authors, and reset readme to gbdev
Rakefile
init.rb initial checkin
validates_as_phone_number.gemspec bump revision, merge pivotal authors, and reset readme to gbdev

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.
Something went wrong with that request. Please try again.