validates_phone_format_of
Validate phone numbers against E.164 format.
Installation
validates_phone_format_of is distributed as a gem, which is how it should be used in your app.
Include the gem in your Gemfile:
gem 'validates_phone_format_of', '~> 1.0'
Usage
In your model
class User < ActiveRecord::Base
validates :phone, phone_format: true
# Or
validates_phone_format_of :phone
# Same thing as
validates_format_of :phone, with: ValidatesPhoneFormatOf::Regexp
# Or
validates_format_of :phone, with: /\A\+?[1-9]\d{1,14}\z/
end
Author
License
validates_phone_format_of is released under the MIT license. See the LICENSE file for more info.