No commit activity in last 3 years
No release in over 3 years
Validate and set phone number format
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

SimplePhoneNumber

Install

gem install simple_phone_number

Example

SimplePhoneNumber will accept the following phone formats: 1234567890, 123-456-7890, 123.456.7890, 123 456 7890 and (123) 456 7890

and save the record in 123-456-7890 format

class User < ActiveRecord::Base
  simple_phone_number :home_phone, :cell_phone
end

Options

simple_phone_number :home_phone, :validate => false, :allow_blank => true
simple_phone_number :home_phone, :validate_on => :update, :validate_if => proc{|record| record.something?}
simple_phone_number :home_phone, :validation_message => "should look like 1234567890, 123-456-7890, 123.456.7890, 123 456 7890 or (123) 456 7890"

Also,

validates_simple_phone_number :cell_phone, :if => proc{|record| record.home_phone.blank?}