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
}
I'm using
IsPhoneNumber('US')to validate US numbers but for example a Puerto Rico phone number is returning false.The problem:
Looking at
isPhoneNumberdecorator source code I saw this:So... basically a phone number from Puerto Rico is from the country
PRbut the region is US. The decorator is returning false is this the expected behavior?For example this is the result from
parsePhoneNumberfor a Puerto Rico phone number: