I'm using libphonenumber
from Google. I want to customize some data of this library U cloned the Project then I modify in resources/PhoneNumberMetadata.xml
.
Then I changed the Mobile Number related to Egypt from 10 to 15 Number.
<territory id="EG" countryCode="20" internationalPrefix="00" nationalPrefix="0"
mobileNumberPortableRegion="true">
<availableFormats>
<numberFormat pattern="(\d)(\d{7,8})" nationalPrefixFormattingRule="$NP$FG">
<leadingDigits>[23]</leadingDigits>
<format>$1 $2</format>
</numberFormat>
<numberFormat pattern="(\d{2})(\d{6,7})" nationalPrefixFormattingRule="$NP$FG">
<leadingDigits>
1[35]|
[4-6]|
8[2468]|
9[235-7]
</leadingDigits>
<format>$1 $2</format>
</numberFormat>
<numberFormat pattern="(\d{3})(\d{3})(\d{4})" nationalPrefixFormattingRule="$NP$FG">
<leadingDigits>[189]</leadingDigits>
<format>$1 $2 $3</format>
</numberFormat>
</availableFormats>
<generalDesc>
<nationalNumberPattern>
[189]\d{8,9}|
[24-6]\d{8}|
[135]\d{7}
</nationalNumberPattern>
</generalDesc>
<!-- Subscriber numbers starting with 5 are also permitted for the area codes 040, with 5, 6
and 7 for the area code 050, with 5 and 7 for 082, with 6 for 084, with 7 for 086 and
092 and with 5 and 6 for 96. -->
<fixedLine>
<possibleLengths national="8,9" localOnly="6,7"/>
<exampleNumber>234567890</exampleNumber>
<nationalNumberPattern>
(?:
15\d|
57[23]
)\d{5,6}|
(?:
13[23]|
(?:
2[2-4]|
3
)\d|
4(?:
0[2-5]|
[578][23]|
64
)|
5(?:
0[2-7]|
5\d
)|
6[24-689]3|
8(?:
2[2-57]|
4[26]|
6[237]|
8[2-4]
)|
9(?:
2[27]|
3[24]|
52|
6[2356]|
7[2-4]
)
)\d{6}
</nationalNumberPattern>
</fixedLine>
<mobile>
<possibleLengths national="15"/>
<exampleNumber>100123456712345</exampleNumber>
<nationalNumberPattern>1[0-25]\d{13}</nationalNumberPattern>
</mobile>
<tollFree>
<possibleLengths national="10"/>
<exampleNumber>8001234567</exampleNumber>
<nationalNumberPattern>800\d{7}</nationalNumberPattern>
</tollFree>
<premiumRate>
<possibleLengths national="10"/>
<exampleNumber>9001234567</exampleNumber>
<nationalNumberPattern>900\d{7}</nationalNumberPattern>
</premiumRate>
</territory>
Then I build the Project then I take the Jar in my Project to depend on the New Jar but still see that Mobile Number is 10 Numbers not 15 that is the Code I wrote
public static void main(String argc[])
{
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
try {
Phonenumber.PhoneNumber egyNumber = phoneUtil.parse("152234567891234", "EG");
boolean isValidNumber = phoneUtil.isValidNumber(egyNumber);
System.out.println(isValidNumber);
} catch (NumberParseException e) {
e.printStackTrace();
}
}
This code return FALSE
but it should return TRUE
.
Note: The Library use Binary File for each Country, but I think it's encoded.
i found that Google provides a way to customize the Metadata related to any Country through some steps you can find them here
https://github.com/google/libphonenumber/blob/master/making-metadata-changes.md