CogiPhony
This gem provide you library to validate, parsing, format and normalize phone number, detect phone network in Vietnam.
It uses the super awesome Phony gem (https://github.com/floere/phony).
Installation
Add this line to your application's Gemfile:
gem 'cogi_phony'
And then execute:
$ bundle
Or install it yourself as:
$ gem install cogi_phony
Usage
Validation
Check if a string is a valid phone number.
CogiPhony.validate? '+14037089189'
Normalization
Normalize phone numer to international format.
CogiPhony.normalize '+1 (403) 708-9189'
Formatting
Format formats phone numbers according to the predominant format of a country.
CogiPhony.format '+84933081090'
CogiPhony.format '+84933081090', format: 'global'
CogiPhony.format '+84933081090', format: 'vietnam'
Extract country code from phone number.
CogiPhony.country_code_from_number '+84933081090'
Check if Vietnam mobile phone
Check if phone number is Vietnam mobile phone format
CogiPhony.vn_mobile_phone? '+84933081090'
Phone provider
Return phone provider from phone number.
CogiPhony.phone_to_provider '+84933081090'
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Don't forget to add tests and run rspec before creating a pull request :)
See all contributors on https://github.com/hoahm/cogi_phony/graphs/contributors.