[Bug] Phone number validation – wrong and inconsistent

Cardbook for Thunderbird Forums Main Forum [Bug] Phone number validation – wrong and inconsistent

This topic contains 11 replies, has 4 voices, and was last updated by Avatar cbb 2 months, 2 weeks ago.

  • Author
    Posts
  • #2337
    Avatar
    kawigonebemi
    Participant

    I have to revise my excitement about the feature of phone number validation since it seems to produce wrong and inconsistent results.
    <h1>Wrong</h1>
    Entering a German number from Bavaria such as

    097219779030

    and then clicking the validation button will result in

    +49 972 19779030

    The correct result though should be

    +49 9721 9779030

    because the (0)9721 is the area code.
    <h1>Inconsistent (and wrong)</h1>
    Entering a German number from Bavaria such as

    097219408731

    and then clicking the validation button will result in

    +49 97 219408731

    Compared to the first number given the “2” of the area code is now even moved further back.

    Entering these phone numbers in the contact app on my Android smartphone it gets corrected to the proper format.

  • #2338
    CardBook
    CardBook
    Keymaster

    what is your region code in CardBook preferences, second tab ?

    • #2339
      Avatar
      kawigonebemi
      Participant

      CardBook Preferences -> CardBook Tab -> Standardregion
      is set to “Deutschland”.

      I hope this is the setting you were asking me for.

      <hr />

      FYI, other German phone numbers such as from Berlin (area code 030), Potsdam (area code 0331) or Nuremburg (area code 0911) seem to be treated correctly.

      But there are other inconsistencies for the same area code, e. g.

      +49 97 239389789
      +49 9723 2412

  • #2340
    CardBook
    CardBook
    Keymaster

    cannot help, my library comes from this one : https://github.com/andreasgal/PhoneNumber.js

    • #2341
      Avatar
      kawigonebemi
      Participant

      That library seems old (last commit March 2015) and generally flawed as there is an issue on “Wrong Format for some Numbers from Austria #35” with the supposed problem being “The bug has to be in the Python script which generates the PhoneNumberMetadata.js”. Unfortunately no reply to this has ever been given.

      I assume the Google library “libphonenumber” would be overkill:
      https://github.com/googlei18n/libphonenumber

      But there is a library rewrite of this which seems in active development:
      https://github.com/catamphetamine/libphonenumber-js

      I don’t know if you could replace the current one in CardBook with this and how much work that would mean – but right now the validation functionality is not reliable.

  • #2342
    CardBook
    CardBook
    Keymaster

    nice but where is the library libphonenumber-js to integrate ?

  • #2346
    CardBook
    CardBook
    Keymaster

    I wasn’t unable to integrate it 🙁 …. if you know someone able to do it, do not hesitate ;O)

  • #2431
    Avatar
    kTDK
    Participant

    Hi, I have problems with the phone number verification too. Some German landline numbers are not parsed correctly.

    I tested these numbers with the demo from here: https://catamphetamine.github.io/libphonenumber-js/

    It works without errors. So it seems catamphetamine’s libphonenumber-js is working better than that of andreasgal.

    Maybe Nikolay (catamphetamine) could help you with some integration issues.

    But if that isn’t possible, you could make an option to disable this feature.

  • #2432
    CardBook
    CardBook
    Keymaster

    according to Nikolay it should be easy (https://github.com/catamphetamine/libphonenumber-js/issues/277) but not easy enough for me 🙁

  • #2433
    Avatar
    kTDK
    Participant

    Ah, Ok. You had already created an issue at his repo.

    Could you install it via npm or yarn?

    I’m not very familiar with javascript, but I try to educate myself a bit further.

  • #2449
    Avatar
    cbb
    Participant

    This would be an awesome improvement. There is one more idea: Would it be possible the add some spaces?

    In Germany, the official format is +49 AAAA BBBBBBBB, where

    • +49 is the country code,
    • AAAA is the area code and
    • BBBBBBBB is the remaining digits of the subscriber number.

    The last part is often clustered, the old format being +49 AAAA BB BB BB BB (inserting a space every two digits, counted from the right).

    The modern format is to insert a space every four digits from the left, yielding +49 AAAA BBBB BBBB, which is very handy if you are to read the number to somebody.

    The current phone validation just removes those spaces if existent rather than inserting them if not existent.

You must be logged in to reply to this topic.