Hungarian number is formatted in NATIONAL wrongly
Closed this issue · 2 comments
Laravel-Phone version
5.3.0
Steps to reproduce
Use magic function:
phone("+36 70 510 4452", "HU", \libphonenumber\PhoneNumberFormat::NATIONAL)
Result:
"6705104452"
Observed vs Expected behavior
Result of:
phone("+36 70 510 4452", "HU", \libphonenumber\PhoneNumberFormat::NATIONAL)
should be:
"705104452"
Is wrong because after if I try to convert back with:
phone("6705104452", "HU", \libphonenumber\PhoneNumberFormat::E164)
it will throw error:
"Number does not match the provided country"
but with:
phone("705104452", "HU", \libphonenumber\PhoneNumberFormat::E164)
will work, also tested on validation demo pages.
The national format for this number is "06 70 510 4452"
according to libphonenumber:
I can see that "6705104452"
does not match "06 70 510 4452"
.
Apart from spaces being stripped (which is fine), it's missing the leading zero (which is crucial).
Are you sure you don't apply additional formatting to that value?
"6705104452"
can never be the direct output of phone("+36 70 510 4452", "HU", \libphonenumber\PhoneNumberFormat::NATIONAL)
@Propaganistas The issue was on my side. I did a trim of 0 before saving and that brake the conversion from NATIONAL to INTERNATIONAL. I thought is OK as it worked with other countries.
Thank you for leading the info about crucial 0