Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile number validation doesn't completely work #121

Closed
kuyazee opened this issue Feb 27, 2017 · 11 comments
Closed

Mobile number validation doesn't completely work #121

kuyazee opened this issue Feb 27, 2017 · 11 comments

Comments

@kuyazee
Copy link
Collaborator

kuyazee commented Feb 27, 2017

The default value for PH mobile numbers look like this +639xxxxxxxxx or 09xxxxxxxxx, but the library validates +6309xxxxxxxxx as a correct number.

For ID too it doesn't validate the numbers correctly, it this time it won't accept correct values for the numbers

Here's my code

let raw = "Some Number Here"
do {
     let number = try PhoneNumber(rawNumber: raw)
     print(number.isValidNumber, number.rawNumber)
} catch {
     print("Phone number parsing error", error)
}
@marmelroy
Copy link
Owner

Hi @kuyazee,

PhoneNumberKit is using metadata from Google's libPhoneNumber project that powers most mobile phone number validation on the web and on mobile.

They consider +6309xxxxxxxxxx as a correct format for PH. See: https://libphonenumber.appspot.com/phonenumberparser?number=%2B630918+899+2866&country=PH

@kuyazee
Copy link
Collaborator Author

kuyazee commented Apr 11, 2017

@marmelroy actually it isn't cause I live in the Philippines and there is no such number that is +6309(10 digits) what you showed i.e. this is +6309(9 digits) which is possible.

+6309(10 digits) Not valid
+6309(9 digits) valid

@marmelroy
Copy link
Owner

I had one extra x in my reply.

This is the number I tested with:
+630918 899 2866

Again, please see:
https://libphonenumber.appspot.com/phonenumberparser?number=%2B630918+899+2866&country=PH

@bargangilo
Copy link

bargangilo commented Apr 27, 2017

@marmelroy: I'm also having issues getting PhoneNumberKit to validate a mobile number from the Philippines. No matter how I enter the number in I either get notANumber or unknownType errors.

For example:
https://libphonenumber.appspot.com/phonenumberparser?number=%2B639561331299&country=63

Libphonenumber sees this as valid, but PHK won't validate it. Even with the simulator set to the Philippines region.

@marmelroy
Copy link
Owner

hi @bargangilo, libPhoneNumber also says that this number is invalid. isValidNumberForRegion is false in the link you attached.

@bargangilo
Copy link

@marmelroy: Ok, if I add the zero in it also returns isValidNumberForRegion as false. I guess this is a libphonenumber issue then? Because I most definitely have a working number.

Is PHK only looking at the isValidNumberForRegion? Is there any way to turn that off and only check isValidNumber and isPossibleNumber?

@marmelroy
Copy link
Owner

In the Swift 2.3 version there's no way to turn it off. In the Swift 3.0 version there is a way to ignore the type validation, which is close to Goolgle's isValidNumber.

@bargangilo
Copy link

But not the regional validation?

@bargangilo
Copy link

Also I've submitted an issue to libphonenumber: https://github.com/googlei18n/libphonenumber/issues/1710

@marmelroy
Copy link
Owner

the type validation is the same thing as the regional validation

@johnolwamba
Copy link

Is there an example number? I have looked it up and not found it. Its there in libphonenumber. Please assist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants