From c9e9b231b7d8aa96ae0ddb8a3901d23f1d11c4cb Mon Sep 17 00:00:00 2001 From: Abdullah Danyal Saeed Date: Mon, 16 Dec 2019 13:21:45 +0200 Subject: [PATCH 1/2] Add support for armenia phone --- src/lib/isMobilePhone.js | 1 + test/validators.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index 154f6ead3..85f1515aa 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -2,6 +2,7 @@ import assertString from './util/assertString'; /* eslint-disable max-len */ const phones = { + 'am-AM': /^(\+?374|0)(10\d{6}$|[2-4]\d{7}$|[9][1-4]\d{6}$)/, 'ar-AE': /^((\+?971)|0)?5[024568]\d{7}$/, 'ar-BH': /^(\+?973)?(3|6)\d{7}$/, 'ar-DZ': /^(\+?213|0)(5|6|7)\d{8}$/, diff --git a/test/validators.js b/test/validators.js index 5721212d2..8a9e77569 100644 --- a/test/validators.js +++ b/test/validators.js @@ -3738,6 +3738,25 @@ describe('Validators', () => { it('should validate mobile phone number', () => { let fixtures = [ + { + locale: 'am-AM', + valid: [ + '+37410324123', + '+37422298765', + '+37431276521', + '022698763', + '37491987654', + '+37494567890', + ], + invalid: [ + '12345', + '+37411498855', + '+37411498123', + '05614988556', + '', + '37456789000', + ], + }, { locale: 'ar-AE', valid: [ From 819eff4744a194bdf624be65ea25eb45593997fa Mon Sep 17 00:00:00 2001 From: Abdullah Danyal Saeed Date: Mon, 16 Dec 2019 14:12:45 +0200 Subject: [PATCH 2/2] Modify regex to support other mobile carriers --- src/lib/isMobilePhone.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index 85f1515aa..a8fe5df0e 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -2,7 +2,7 @@ import assertString from './util/assertString'; /* eslint-disable max-len */ const phones = { - 'am-AM': /^(\+?374|0)(10\d{6}$|[2-4]\d{7}$|[9][1-4]\d{6}$)/, + 'am-AM': /^(\+?374|0)((10|[9|7][0-9])\d{6}$|[2-4]\d{7}$)/, 'ar-AE': /^((\+?971)|0)?5[024568]\d{7}$/, 'ar-BH': /^(\+?973)?(3|6)\d{7}$/, 'ar-DZ': /^(\+?213|0)(5|6|7)\d{8}$/,