Skip to content

Commit

Permalink
feat: (isMobilePhone): add Cameroon fr-CM locale (#1772)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
tarob0ba committed Oct 31, 2021
1 parent 5773869 commit f2381e0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/isMobilePhone.js
Expand Up @@ -76,6 +76,7 @@ const phones = {
'fi-FI': /^(\+?358|0)\s?(4(0|1|2|4|5|6)?|50)\s?(\d\s?){4,8}\d$/,
'fj-FJ': /^(\+?679)?\s?\d{3}\s?\d{4}$/,
'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
'fr-CM': /^(\+?237)6[0-9]{8}$/,
'fr-FR': /^(\+?33|0)[67]\d{8}$/,
'fr-GF': /^(\+?594|0|00594)[67]\d{8}$/,
'fr-GP': /^(\+?590|0|00590)[67]\d{8}$/,
Expand Down
15 changes: 15 additions & 0 deletions test/validators.js
Expand Up @@ -7568,6 +7568,21 @@ describe('Validators', () => {
'088-320000',
],
},
{
locale: 'fr-CM',
valid: [
'+237677936141',
'237623456789',
'+237698124842',
'237693029202',
],
invalid: [
'NotANumber',
'+(703)-572-2920',
'+237 623 45 67 890',
'+2379981247429',
],
},
{
locale: 'ko-KR',
valid: [
Expand Down

0 comments on commit f2381e0

Please sign in to comment.