Last active
August 29, 2015 14:08
-
-
Save brian3kb/82b0387543f8ccade162 to your computer and use it in GitHub Desktop.
ChanceJS UK Phone Numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
ChanceJS (http://chancejs.com) doesn't do UK phone numbers, but you can get close by using chance.string with a | |
pool of numbers 0-9 and length 9, then running it through replace with a bit of regex and | |
adding a 01 for landline or a 07 for mobiles that will come out correctly formatted with spaces. | |
Not perfect, and most numbers not real, but it looks better than the US numbers when testing. | |
*/ | |
var contactNumbers = { | |
telephone: chance.string({pool: '0123456789', length: 9}).replace(/(\d{2})(\d{3})/g, "01$1 $2 "), | |
mobile: chance.string({pool: '0123456789', length: 9}).replace(/(\d{2})(\d{3})/g, "07$1 $2 ") | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment