Skip to content

Commit 03fb998

Browse files
tarob0baprofnandaa
authored andcommitted
feat: (isMobilePhone): add Cameroon fr-CM locale (#1772)
* Add Cameroon validation regex I have added a regex for validating Cameroonian mobile numbers which should work. I'm not super comfortable with regular expressions, so if I have screwed something up, please let me know. I have done some basic testing and it has functioned fine thus far. * Update README to include fr-CM in isMobilePhone * Add (very) basic testing for Cameroonian mobile number * Fix missing brace (whoops!) * Fix commas (I hope) * Fix sloppy tests Fix my sloppy tests. I'm really tired and probably should not be working on this, but I accidentally added an extra digit while typing. * Update regex for correctness Add mobile prefix (6) to regex, remove space allowance, and optimize regex * Update tests for correctness * Remove invalid space Sorry! * Rerun failed tests (internal server error)
1 parent e02a568 commit 03fb998

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/lib/isMobilePhone.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const phones = {
7777
'fi-FI': /^(\+?358|0)\s?(4(0|1|2|4|5|6)?|50)\s?(\d\s?){4,8}\d$/,
7878
'fj-FJ': /^(\+?679)?\s?\d{3}\s?\d{4}$/,
7979
'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
80+
'fr-CM': /^(\+?237)6[0-9]{8}$/,
8081
'fr-FR': /^(\+?33|0)[67]\d{8}$/,
8182
'fr-GF': /^(\+?594|0|00594)[67]\d{8}$/,
8283
'fr-GP': /^(\+?590|0|00590)[67]\d{8}$/,

test/validators.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7592,6 +7592,21 @@ describe('Validators', () => {
75927592
'088-320000',
75937593
],
75947594
},
7595+
{
7596+
locale: 'fr-CM',
7597+
valid: [
7598+
'+237677936141',
7599+
'237623456789',
7600+
'+237698124842',
7601+
'237693029202',
7602+
],
7603+
invalid: [
7604+
'NotANumber',
7605+
'+(703)-572-2920',
7606+
'+237 623 45 67 890',
7607+
'+2379981247429',
7608+
],
7609+
},
75957610
{
75967611
locale: 'ko-KR',
75977612
valid: [

0 commit comments

Comments
 (0)