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

isValidPhoneNumber returning true ignoring region #789

Open
4 tasks done
miguelgazela opened this issue Aug 1, 2024 · 3 comments
Open
4 tasks done

isValidPhoneNumber returning true ignoring region #789

miguelgazela opened this issue Aug 1, 2024 · 3 comments

Comments

@miguelgazela
Copy link

New Issue Checklist

Steps to reproduce

I'm trying to validate a phone number provided for a specific region, but if I give it with the country code behind it ignores the region I'm passing it and considers it valid.

let validPhoneNumber = phoneNumberKit?.isValidPhoneNumber("+351916693528", withRegion: "US")
Expected result

validPhoneNumber should be false

Actual result

validPhoneNumber is true

@bguidolim
Copy link
Collaborator

If you are using the international code, you shouldn't send the region.
The parsing logic contains a couple of fallbacks to always try to bring the right result in the end, so if you send the international code AND the region, when the parsing for the region fails, it will fallback to the international code.

@miguelgazela
Copy link
Author

Ok, so there's no way to enforce the region on the validation, right?

@bguidolim
Copy link
Collaborator

Right.

You can send the phone number without the international code.

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

2 participants