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

Problem on parsing numbers that starts with 0685 #218

Open
yann120 opened this issue Feb 17, 2021 · 1 comment
Open

Problem on parsing numbers that starts with 0685 #218

yann120 opened this issue Feb 17, 2021 · 1 comment

Comments

@yann120
Copy link

yann120 commented Feb 17, 2021

Hello,

We have found an edge case bug with the parse function of Phonelib.

Phonelib.parse(number) works fine for every 10 digits french numbers like 0635374637

but with numbers starting with 0685, it have a weird behaviour.

For exemple parsing the number 0685123456 will have this output

[4] pry(main)> Phonelib.parse('0685123456')
=> #<Phonelib::Phone:0x00007f888cf92a88
 @data=
  {"WS"=>
    {:id=>"WS",
     :country_code=>"685",
     :international_prefix=>"0",
     :national=>"123456",
     :format=>{:pattern=>"(\\d+)(\\d{3})(\\d{4})", :format=>"$1 $2 $3"},
     :valid=>[],
     :possible=>[:toll_free, :fixed_line]}},
 @extension="",
 @national_number="123456",
 @original="0685123456",
 @original_s="0685123456",
 @sanitized="0685123456">

It understands that the country code is 685 and the national number 123456

the national number should be 0685123456 and not 123456

Any idea how we could fix this ?

Thanks ! 😄

@daddyz
Copy link
Owner

daddyz commented Mar 14, 2021

@yann120 do you have any way to provide country for phone validator? Or in case you are parsing french phones only you can define default_country for the gem.

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

2 participants