Hi,

Landline ("Work") numbers are not validating correctly:

The number "061 123 1234" is not a valid phone number for Namibia. The expected format is 061 201 2345.
The number "061 123 123" is not a valid phone number for Namibia. The expected format is 061 201 2345.

Both of these should be valid. I'm not sure where in to change this. Presumably in PhoneNumberMetadata_NA. Could someone assist?

Thanks.

Comments

cdale’s picture

The 2.x branch uses libphonenumber for valdiation, which is ported from the java libphonenumber made by google at http://libphonenumber.googlecode.com/.

Google uses the itu standards to define the parsing rules, and the patterns for Nambia can be found in the documents at http://www.itu.int/oth/T0202000093/en.

Now, this document has no mention of numbers starting with 6112. The only numbers allowed according to that document that start with 611, are 6117* numbers. So in short, your numbers are really not valid. Try using actual phone numbers instead of dummy numbers and things should work out just fine.

namwebs’s picture

Thanks for your reply.

I was using actual phone numbers in the website... I just didn't put those in the post. I looked at the doc you indicated and there it lists under Windhoek (which is 61) codes under 370000 – 379999 as "BRA DID / Office Codes" yet when I try to validate 061 377500 it isn't accepted, though it is a real number and should be accepted. What now?

cdale’s picture

I'm sorry, I don't know much about Nambia numbers, and all of the validation code is handled by the libphonenumber API's.

Below is the XML metadata used to create the regular expressions to match against, the key thing to look at is the giant regular expression for the nationalNumberPattern. This is actually the pattern that is used to validate numbers against, and this is the pattern that libphonenumber is using, and it doesn't appear to allow 061 377500.

Looking at the ITU plan, this does seem like a bug, and will probably need to be raised with at https://code.google.com/p/libphonenumber/ about Nambia phone numbers.

For now, I'm not sure what approach the phone module should take, whether it should allow some sort of override..... We'll need to think about this.


<!-- Namibia -->
    <!-- http://www.itu.int/oth/T0202000093/en -->
    <territory id="NA" countryCode="264" internationalPrefix="00"
               nationalPrefix="0" nationalPrefixFormattingRule="$NP$FG">
      <availableFormats>
        <numberFormat pattern="(8\d)(\d{3})(\d{4})">
          <leadingDigits>8[1235]</leadingDigits>
          <format>$1 $2 $3</format>
        </numberFormat>
        <numberFormat pattern="(6\d)(\d{2,3})(\d{4})">
          <leadingDigits>6</leadingDigits>
          <format>$1 $2 $3</format>
        </numberFormat>
        <numberFormat pattern="(88)(\d{3})(\d{3})">
          <leadingDigits>88</leadingDigits>
          <format>$1 $2 $3</format>
        </numberFormat>
        <numberFormat pattern="(870)(\d{3})(\d{3})">
          <leadingDigits>870</leadingDigits>
          <format>$1 $2 $3</format>
        </numberFormat>
      </availableFormats>
      <generalDesc>
        <nationalNumberPattern>[68]\d{7,8}</nationalNumberPattern>
        <possibleNumberPattern>\d{8,9}</possibleNumberPattern>
      </generalDesc>
      <fixedLine>
        <!-- Includes VSAT service. -->
        <nationalNumberPattern>
          6(?:
            1(?:
              17|
              2(?:
                [0189]\d|
                [2-6]|
                7\d?
              )|
              3(?:
                2\d|
                3[378]
              )|
              4[01]|
              69|
              7[014]
            )|
            2(?:
              17|
              25|
              5(?:
                [0-36-8]|
                4\d?
              )|
              69|
              70
            )|
            3(?:
              17|
              2(?:
                [0237]\d?|
                [14-689]
              )|
              34|
              6[29]|
              7[01]|
              81
            )|
            4(?:
              17|
              2(?:
                [012]|
                7?
              )|
              4(?:
                [06]|
                1\d
              )|
              5(?:
                [01357]|
                [25]\d?
              )|
              69|
              7[01]
            )|
            5(?:
              17|
              2(?:
                [0459]|
                [23678]\d?
              )|
              69|
              7[01]
            )|
            6(?:
              17|
              2(?:
                5|
                6\d?
              )|
              38|
              42|
              69|
              7[01]
            )|
            7(?:
              17|
              2(?:
                [569]|
                [234]\d?
              )|
              3(?:
                0\d?|
                [13]
              )|
              69|
              7[01]
            )
          )\d{4}
        </nationalNumberPattern>
        <exampleNumber>612012345</exampleNumber>
      </fixedLine>
      <mobile>
        <!-- Includes the Switch CDMA Service. -->
        <nationalNumberPattern>
          (?:
            60|
            8[125]
          )\d{7}
        </nationalNumberPattern>
        <possibleNumberPattern>\d{9}</possibleNumberPattern>
        <exampleNumber>811234567</exampleNumber>
      </mobile>
      <premiumRate>
        <nationalNumberPattern>8701\d{5}</nationalNumberPattern>
        <possibleNumberPattern>\d{9}</possibleNumberPattern>
        <exampleNumber>870123456</exampleNumber>
      </premiumRate>
      <voip>
        <!-- Including virtual telephone and VOIP services. -->
        <nationalNumberPattern>
          8(
            3\d{2}|
            86
          )\d{5}
        </nationalNumberPattern>
        <exampleNumber>88612345</exampleNumber>
      </voip>
      <shortCode>
        <nationalNumberPattern>
          1\d{3}|
          9(?:
            3111|
            \d{2}
          )
        </nationalNumberPattern>
        <possibleNumberPattern>\d{3,5}</possibleNumberPattern>
        <exampleNumber>93111</exampleNumber>
      </shortCode>
      <emergency>
        <!-- ITU doc reserves 9XX for emergency numbers. No examples found. -->
        <!-- http://www.namibia-1on1.com/information/a-emergencynos.html -->
        <nationalNumberPattern>10111</nationalNumberPattern>
        <possibleNumberPattern>\d{5}</possibleNumberPattern>
        <exampleNumber>10111</exampleNumber>
      </emergency>
    </territory>

namwebs’s picture

Okay, thanks for the explanation.