A Ruby gem for phone number validation, formatting, and parsing using Google's libphonenumber data.
Phonelib is a Ruby gem designed for validating, parsing, and formatting phone numbers using data from Google's libphonenumber library. It solves the problem of handling international phone numbers accurately by providing robust validation against country-specific patterns and supporting various phone types. The gem integrates seamlessly with Ruby on Rails applications through an ActiveRecord validator.
Ruby and Rails developers who need reliable phone number validation and formatting in their applications, particularly those dealing with international user data or multi-country services.
Developers choose Phonelib because it leverages Google's authoritative libphonenumber data, ensuring high accuracy, while offering a simple Ruby-friendly API, ActiveRecord integration, and flexibility for custom regex patterns and country-specific handling.
Ruby gem for phone validation and formatting using google libphonenumber library data
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Leverages Google's libphonenumber library, ensuring accurate and up-to-date validation patterns for international numbers across many countries and phone types.
Includes built-in ActiveRecord validators with customizable options like type-specific validation (e.g., :mobile or :voip) and dynamic country specifiers, making it easy to integrate into Rails applications.
Allows adding custom regex patterns for specific countries and phone types using Phonelib.add_additional_regex, and supports overriding phone data for edge cases not covered by default.
Formats numbers into international (E.164), national, and local representations, with support for extensions, vanity conversions, and configurable separators.
The README explicitly states it 'doesn't include all Google's library functionality,' which means advanced features like geocoding or carrier detection might be limited or absent.
Setting up custom regexes or data overrides requires manual configuration and understanding of the internal data structure, which can be cumbersome and error-prone for developers.
As a Ruby gem, it's not suitable for polyglot projects or environments outside the Ruby ecosystem, forcing teams to find alternatives for other programming languages.
Updates to phone number data depend on Google's libphonenumber, and Phonelib might not immediately reflect changes, potentially leading to temporary inaccuracies in validation.