Closed bdewater-thatch closed 1 month ago
Libphonenumber demo:
****Parsing Result:**** {"country_code":1,"national_number":8889653214,"raw_input":"+1(888) 965-3214","country_code_source":1} ****Validation Results:**** Result from isPossibleNumber(): true Result from isValidNumber(): true Result from isValidNumberForRegion(): true Phone Number region: US Result from getNumberType(): TOLL_FREE ****Formatting Results:**** E164 format: +18889653214 Original format: +1 888-965-3214 National format: (888) 965-3214 International format: +1 888-965-3214 Out-of-country format from US: 1 (888) 965-3214 Out-of-country format from Switzerland: 00 1 888-965-3214 Format for mobile dialing (calling from US): +1 888-965-3214 Format for national dialing with preferred carrier code and empty fallback carrier code: (888) 965-3214 ****AsYouTypeFormatter Results**** Char entered: + Output: + Char entered: 1 Output: +1 Char entered: ( Output: +1( Char entered: 8 Output: +1(8 Char entered: 8 Output: +1(88 Char entered: 8 Output: +1(888 Char entered: ) Output: +1(888) Char entered: Output: +1(888) Char entered: 9 Output: +1(888) 9 Char entered: 6 Output: +1(888) 96 Char entered: 5 Output: +1(888) 965 Char entered: - Output: +1(888) 965- Char entered: 3 Output: +1(888) 965-3 Char entered: 2 Output: +1(888) 965-32 Char entered: 1 Output: +1(888) 965-321 Char entered: 4 Output: +1(888) 965-3214
Gem:
phone = Phonelib.parse "+1(888) 965-3214", "US" phone.valid? # => true phone.types # => [:toll_free] phone.area_code # => nil
I was expecting this to return 888 instead of nil?
@bdewater-thatch this actually makes sense, area code is impossible for tollfree numbers, it's a non-geographical phone number. It is returned for fixed or mobile phones only.
Libphonenumber demo:
Gem:
I was expecting this to return 888 instead of nil?