Strict validation module for phone numbers that supports classifications and areas
Clone or download
Pull request Compare This branch is 16 commits ahead of kristinalim:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



Strict validation module for phone numbers that supports classifications and

= General usage

== Installation

You can install the plugin the traditional way. Go to your application root
and do:

  script/plugin install git://

== Validate your model attributes


There are three ways to specify the country:
 (1) Pass the country name in as a string parameter (:country => "CA")
 class Person < ActiveRecord::Base
   validates_as_phone :phone, :country => "CA", :allow_blank => true, :set => true

 (2) Create an attribute (country field) named foo in your object, and pass in a reference to foo:

 class Person < ActiveRecord::Base
   validates_as_phone :phone, :country => :foo

 (3) Create an attribute named country it in your object, i.e. Person#country
     i.e. country is the default name for your country field, and the validator tries that automatically

 class Person < ActiveRecord::Base
   validates_as_phone :phone

The :set parameter tells the validator to reformat the phone number (change punctuation and spacing) in to a standard format.

Supported countries are Canada (CA), the United States (US) and Australia (AU).

= License

Written by Kristina Lim (

Copyright (c) 2008 Syndeo Media

US and Canada support added by Paul Schreiber (
Last modified 07 September 2010
Extension support added 17 November 2010

= Contributing

If you wish to contribute to the project, you may contact the author through:

'kristinasyndeomediacom'.insert(8, '@').insert(20, '.')

= Acknowledgements

This plugin is named after the validates_as_phone plugin of Jerrod Blavos
( Admittedly, this plugin was
built over the latter, but as the purposes of this plugin is more complex than
that of the minimal one, practically all of the code has been written over by