sstephenson / global_phone

Parse, validate, and format phone numbers in Ruby using Google's libphonenumber database
MIT License
549 stars 104 forks source link

Add global_phone validator #10

Closed locochris closed 8 years ago

locochris commented 11 years ago

Validate global phone numbers in Rails 3.x and ActiveModel.

class Person < ActiveRecord::Base
  validates :home_phone, :global_phone => true
end

Person.new(home_phone: '+61 3 9876 0010').valid?
# => true

class User < ActiveRecord::Base
  validates :work_phone, :global_phone => { :using => :work_country_code }

  def work_country_code
    'AU'
  end
end

User.new(work_phone: '03 9876 0010').valid?
# => true
josh commented 11 years ago

Sorry, but I don't think AR/AM specific code belongs in this gem.

eileencodes commented 8 years ago

Thanks for the PR :+1: I agree with Josh, this gem is meant to pure Ruby and not have dependencies on Rails so I'm going to close this.