cedvdb / phone_numbers_parser

Dart phone number parser, based on libphonenumber and PhoneNumberKit.
https://pub.dev/packages/phone_numbers_parser
MIT License
62 stars 32 forks source link

[FIX] mobile brazilian numbers are 11 digits and fixedLines are 10 #57

Closed klausgreiner closed 9 months ago

klausgreiner commented 9 months ago

I only update mobile and fixed lines, help me understand if I'm missing something about what you wanted. Usually Brazilian phones are defined this way +55 31 9 1234-1234 National Code +55 Followed by state 31 Followed by 9 numbers and 8 numbers if it is a fixed line

![Uploading image.png…]()

cedvdb commented 9 months ago

Hello @klausgreiner

The metadata you modified are auto generated and taken from the google library https://github.com/google/libphonenumber

So those cannot be modified here directly.

I suspect that if you have a problem, the source of the issue is somewhere else (in the validator for example) as someone should have caught an issue like that by now in the libphonenumber library. Having said that, I tried both

        final brValidMobilePhone = '31975228038';
        final brInvalidMobilePhone = '3175228038';

and both seem to be valid with libphonenumber:

https://libphonenumber.appspot.com/phonenumberparser?number=31975228038&country=BR https://libphonenumber.appspot.com/phonenumberparser?number=3175228038&country=BR

klausgreiner commented 9 months ago

I see I was checking the lib that You mentioned and I found something funny (this might be me just being dumb and not understanding everything). Bu here they mention the transition

        <!-- Mobile numbers (post transition, 11 digits). -->
        <numberFormat pattern="(\d{2})(\d{5})(\d{4})" nationalPrefixFormattingRule="($FG)"
                      carrierCodeFormattingRule="$NP $CC ($FG)">

And over here they allow 10,11 numbers since right now mobile phones are always 11 numbers (including area code) and 9 numbers including only local 11 9 6123 4567 funny thing is they have a correct number but they left out that 11 6123 4567 -> not a valid number anymore

      <mobile>
        <possibleLengths national="10,11" localOnly="8,9"/>
        <exampleNumber>11961234567</exampleNumber>
        <nationalNumberPattern>
          (?:
            [14689][1-9]|
            2[12478]|
            3[1-578]|
            5[13-5]|
            7[13-579]
          )(?:
            7|
            9\d
          )\d{7}
        </nationalNumberPattern>
      </mobile>

https://github.com/google/libphonenumber/blob/master/resources/PhoneNumberMetadata.xml

cedvdb commented 9 months ago

I'm not sure I understand you last comment. Do you mean that there is an issue in their metadata ? If so I suggest posting an issue in their repository.

klausgreiner commented 9 months ago

Either that or I'm missing something haha