daddyz / phonelib

Ruby gem for phone validation and formatting using google libphonenumber library data
MIT License
1.04k stars 130 forks source link

Parsing of valid FR cell phone numbers fails in 0.6.47 #212

Closed nicolasrouanne closed 3 years ago

nicolasrouanne commented 3 years ago

Some valid FR cell phone numbers are now considered invalid with release 0.6.47, while they were valid with 0.6.46

For instance

require 'faker'

phone_number =  Faker::Base.numerify('+33 6 ## ## ## ##') 
parsed_phone_number = Phonelib.parse(phone_number)
parsed_phone_number.valid?

Example numbers considered as invalid in 0.6.47 although they are valid in 0.6.46 (and they are indeed valid): +33696339246, +33692746428, +33639538676, +33639891873, +33692018258, etc.

daddyz commented 3 years ago

@nicolasrouanne Hi, I checked these numbers in the original libphonenumber here and number is possible but not valid there. You can open an issue for them

ahubertaircall commented 3 years ago

Hello, We are facing the same issue on our end, FYI I filled a report ticket on libphonenumber side: https://issuetracker.google.com/issues/179166703.

nicolasrouanne commented 3 years ago

Just to sum it up after libphonenumber answered the ticket:

I was generating phones using this pattern Faker::Base.numerify('+33 6 ## ## ## ##'), which actually generates "possible" formats (i.e. with the correct number pattern), but not always "valid" phone numbers. Phone number validation is more complex than just a regex.

I then switched to Faker::PhoneNumber.cell_phone, which seems promising generating valid phone numbers. However, there seems to be an issue in faker's fr locale for valid french phone numbers ATM: https://github.com/faker-ruby/faker/issues/1650, https://github.com/faker-ruby/faker/issues/1957. May be fixed by https://github.com/faker-ruby/faker/pull/1968, but it's not merged at the time of writing.

I'm closing this issue, as it's not a bug, rather a failure on my side to generate random valid test data.