From 659a75855199329bb742bd6528f178cebf394458 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 18 Oct 2019 23:25:04 +0900 Subject: [PATCH] fix(isMobile): allow for extra formatting for ja-JP locale (#1166) * WIP: modified ja-JP check. * WIP: added test cases. * Added one more invalid test case. --- src/lib/isMobilePhone.js | 2 +- test/validators.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index cc4c4f7ab..779bf5369 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -59,7 +59,7 @@ const phones = { 'hu-HU': /^(\+?36)(20|30|70)\d{7}$/, 'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/, 'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/, - 'ja-JP': /^(\+?81|0)[6789]0[ \-]?\d{4}[ \-]?\d{4}$/, + 'ja-JP': /^(\+81[ \-]?(\(0\))?|0)[6789]0[ \-]?\d{4}[ \-]?\d{4}$/, 'kk-KZ': /^(\+?7|8)?7\d{9}$/, '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}$/, diff --git a/test/validators.js b/test/validators.js index aee86d7f1..911daa6be 100644 --- a/test/validators.js +++ b/test/validators.js @@ -4929,6 +4929,10 @@ describe('Validators', () => { '06012345678', '090 1234 5678', '+8190-1234-5678', + '+81 (0)90-1234-5678', + '+819012345678', + '+81-(0)90-1234-5678', + '+81 90 1234 5678', ], invalid: [ '12345', @@ -4949,6 +4953,10 @@ describe('Validators', () => { '03-1234-5678', '+81312345678', '+816-1234-5678', + '+81 090 1234 5678', + '+8109012345678', + '+81-090-1234-5678', + '90 1234 5678', ], }, {