-
Notifications
You must be signed in to change notification settings - Fork 839
Open
Labels
type: questionQuestions about the usage of the library.Questions about the usage of the library.
Description
I'm using IsPhoneNumber('US') to validate US numbers but for example a Puerto Rico phone number is returning false.
The problem:
Looking at isPhoneNumber decorator source code I saw this:
var phoneNumber = parsePhoneNumber(value, region);
/**
* We fail the validation if the user provided a region code
* and it doesn't match with the country code of the parsed number.
**/
if (region && phoneNumber.country !== region) {
return false;
}
So... basically a phone number from Puerto Rico is from the country PR but the region is US. The decorator is returning false is this the expected behavior?
For example this is the result from parsePhoneNumber for a Puerto Rico phone number:
{
country: 'PR',
countryCallingCode: '1',
nationalNumber: '7876xxxxxx',
number: '+17876xxxxxx',
getMetadata: [Function (anonymous)],
__countryCallingCodeSource: undefined
}
Metadata
Metadata
Assignees
Labels
type: questionQuestions about the usage of the library.Questions about the usage of the library.