Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

German phone numbers starting with "1" are considered invalid if prefixed by a "+" #331

Open
gabypancu opened this issue Jan 10, 2025 · 0 comments

Comments

@gabypancu
Copy link

gabypancu commented Jan 10, 2025

German phone numbers that start with a "1" (after the "49" country code) are wrongly considered invalid if there is a "+" at the start of the number.

Phonelib.parse("+491127690778", :de).valid?
=> false
Phonelib.parse("491127690778", :de).valid?
=> true

The two are parsed differently, with a notable difference in the national number - one includes the country code 49 and one doesn't.

Phonelib.parse("+491127690778", :de)
=> #<Phonelib::Phone:0x000000011dadfed0 @original="+491127690778", @extension="", @sanitized="491127690778", @original_s="+491127690778", @data={"DE"=>{:id=>"DE", :country_code=>"49", :international_prefix=>"00", :national_prefix=>"0", :mobile_number_portable_region=>"true", :double_prefix=>true, :national=>"1127690778", :format=>{:pattern=>"(\\d+)(\\d{3})(\\d{4})", :format=>"$1 $2 $3"}, :valid=>[], :possible=>[:premium_rate, :toll_free, :shared_cost, :pager, :uan, :fixed_or_mobile]}}, @national_number="1127690778">
Phonelib.parse("491127690778", :de)
=> #<Phonelib::Phone:0x000000011d3c1a90 @original="491127690778", @extension="", @sanitized="491127690778", @original_s="491127690778", @data={"DE"=>{:id=>"DE", :country_code=>"49", :international_prefix=>"00", :national_prefix=>"0", :mobile_number_portable_region=>"true", :double_prefix=>true, :national=>"491127690778", :format=>{:pattern=>"(\\d{3})(\\d{3,12})", :national_prefix_formatting_rule=>"$NP$FG", :leading_digits=>"2(?:0[1-389]|12[0-8])|3(?:[35-9][15]|4[015])|906|2(?:[13][14]|2[18])|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1", :format=>"$1 $2"}, :valid=>[:fixed_line], :possible=>[:toll_free, :shared_cost, :pager, :uan, :voicemail, :fixed_line]}}, @national_number="491127690778">

When the country code is omitted, we also consider a number starting with "1" to be invalid:

Phonelib.parse("1577374052", :de).valid?
=> false
Phonelib.parse("2577374052", :de).valid?
=> true

The regex likely needs to be updated, as mobile phone numbers in Germany start with "1"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant