Skip to content

Commit

Permalink
Merge pull request #735 from tomhelmer/add-gl-and-fo-phone-validation
Browse files Browse the repository at this point in the history
Add FO/GL mobilehphone validation and update DA validation
  • Loading branch information
chriso authored Oct 9, 2017
2 parents 4149060 + f227da9 commit 3ee2a50
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/lib/isMobilePhone.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ const phones = {
'ar-DZ': /^(\+?213|0)(5|6|7)\d{8}$/,
'ar-EG': /^((\+?20)|0)?1[012]\d{8}$/,
'ar-JO': /^(\+?962|0)?7[789]\d{7}$/,
'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/,
'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/,
'en-US': /^(\+?1)?[2-9]\d{2}[2-9](?!11)\d{6}$/,
'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/,
'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/,
'de-DE': /^(\+?49[ \.\-])?([\(]{1}[0-9]{1,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/,
'da-DK': /^(\+?45)?(\d{8})$/,
'el-GR': /^(\+?30)?(69\d{8})$/,
'en-AU': /^(\+?61|0)4\d{8}$/,
'en-GB': /^(\+?44|0)7\d{9}$/,
Expand All @@ -21,22 +19,26 @@ const phones = {
'en-KE': /^(\+?254|0)?[7]\d{8}$/,
'en-NG': /^(\+?234|0)?[789]\d{9}$/,
'en-NZ': /^(\+?64|0)2\d{7,9}$/,
'en-UG': /^(\+?256|0)?[7]\d{8}$/,
'en-PK': /^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/,
'en-RW': /^(\+?250|0)?[7]\d{8}$/,
'en-TZ': /^(\+?255|0)?[67]\d{8}$/,
'en-UG': /^(\+?256|0)?[7]\d{8}$/,
'en-US': /^(\+?1)?[2-9]\d{2}[2-9](?!11)\d{6}$/,
'en-ZA': /^(\+?27|0)\d{9}$/,
'en-ZM': /^(\+?26)?09[567]\d{7}$/,
'es-ES': /^(\+?34)?(6\d{1}|7[1234])\d{7}$/,
'fi-FI': /^(\+?358|0)\s?(4(0|1|2|4|5|6)?|50)\s?(\d\s?){4,8}\d$/,
'fa-IR': /^(\+?98[\-\s]?|0)9[0-39]\d[\-\s]?\d{3}[\-\s]?\d{4}$/,
'fi-FI': /^(\+?358|0)\s?(4(0|1|2|4|5|6)?|50)\s?(\d\s?){4,8}\d$/,
'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
'fr-FR': /^(\+?33|0)[67]\d{8}$/,
'he-IL': /^(\+972|0)([23489]|5[0248]|77)[1-9]\d{6}/,
'hu-HU': /^(\+?36)(20|30|70)\d{7}$/,
'lt-LT': /^(\+370|8)\d{8}$/,
'id-ID': /^(\+?62|0[1-9])[\s|\d]+$/,
'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/,
'ko-KR': /^((\+?82)[ \-]?)?0?1([0|1|6|7|8|9]{1})[ \-]?\d{3,4}[ \-]?\d{4}$/,
'ja-JP': /^(\+?81|0)\d{1,4}[ \-]?\d{1,4}[ \-]?\d{4}$/,
'kl-GL': /^(\+?299)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
'ko-KR': /^((\+?82)[ \-]?)?0?1([0|1|6|7|8|9]{1})[ \-]?\d{3,4}[ \-]?\d{4}$/,
'lt-LT': /^(\+370|8)\d{8}$/,
'ms-MY': /^(\+?6?01){1}(([145]{1}(\-|\s)?\d{7,8})|([236789]{1}(\s|\-)?\d{7}))$/,
'nb-NO': /^(\+?47)?[49]\d{7}$/,
'nl-BE': /^(\+?32|0)4?\d{8}$/,
Expand All @@ -45,8 +47,8 @@ const phones = {
'pt-BR': /^(\+?55|0)\-?[1-9]{2}\-?[2-9]{1}\d{3,4}\-?\d{4}$/,
'pt-PT': /^(\+?351)?9[1236]\d{7}$/,
'ro-RO': /^(\+?4?0)\s?7\d{2}(\/|\s|\.|\-)?\d{3}(\s|\.|\-)?\d{3}$/,
'en-PK': /^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/,
'ru-RU': /^(\+?7|8)?9\d{9}$/,
'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
'sr-RS': /^(\+3816|06)[- \d]{5,9}$/,
'tr-TR': /^(\+?90|0)?5\d{9}$/,
'uk-UA': /^(\+?38|8)?0\d{9}$/,
Expand Down
55 changes: 55 additions & 0 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -3727,6 +3727,61 @@ describe('Validators', function () {
'740123456',
],
},
{
locale: 'da-DK',
valid: [
'12345678',
'12 34 56 78',
'45 12345678',
'4512345678',
'45 12 34 56 78',
'+45 12 34 56 78',
],
invalid: [
'',
'+45010203',
'ASDFGJKLmZXJtZtesting123',
'123456',
'12 34 56',
'123 123 12',
],
},
{
locale: 'fo-FO',
valid: [
'123456',
'12 34 56',
'298 123456',
'298123456',
'298 12 34 56',
'+298 12 34 56',
],
invalid: [
'',
'+4501020304',
'ASDFGJKLmZXJtZtesting123',
'12345678',
'12 34 56 78',
],
},
{
locale: 'kl-GL',
valid: [
'123456',
'12 34 56',
'299 123456',
'299123456',
'299 12 34 56',
'+299 12 34 56',
],
invalid: [
'',
'+4501020304',
'ASDFGJKLmZXJtZtesting123',
'12345678',
'12 34 56 78',
],
},
];

var allValid = [];
Expand Down

0 comments on commit 3ee2a50

Please sign in to comment.