randPhoneNumber will generate invalid US phone numbers
Akkuma opened this issue · comments
Is this a regression?
No
Description
When randPhoneNumber
is used as randPhoneNumber({ countryCode: 'US' })
the numbers generated are at risk of not being actually valid numbers.
Please provide a link to a minimal reproduction of the bug
https://runkit.com/akkuma/65798236cdff300008bc8b3f
Please provide the exception or error you saw
No errors or exceptions
Please provide the environment you discovered this bug in
node v20
Anything else?
Looking through the code it looks like the simplest solution would be to extend the formats on https://github.com/ngneat/falso/blob/main/packages/falso/src/lib/phone-number.json#L976 to be representative of a list like https://github.com/AfterShip/phone/blob/master/src/data/country_phone_data.ts#L2-L31. Alternatively, could use data like that to dynamically generate the mask formats as to not need to keep updating them.
Do you want to create a pull request?
Yes
You're welcome to create a PR