From ec62c1ddbbbe3aab0e62f3db4c33618b88e7c0c6 Mon Sep 17 00:00:00 2001 From: "PuHsiu, Chiang" <_@m.puhsiu.cc> Date: Tue, 24 Oct 2017 00:52:32 +0800 Subject: [PATCH 1/3] Update the jp mobile phone validator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refer from 1. https://ja.wikipedia.org/wiki/日本の電話番号#0A0_.E7.89.B9.E7.95.AA 2. http://www.soumu.go.jp/main_sosiki/joho_tsusin/top/tel_number/number_shitei.html Japan's mobile number (include 攜帯電話 and PHS) will begin with 070, 080, 090, and all of them didn't apply "0" as 4-th number. --- src/lib/isMobilePhone.js | 2 +- test/validators.js | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index a0768d958..95ec5e629 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -35,7 +35,7 @@ const phones = { 'hu-HU': /^(\+?36)(20|30|70)\d{7}$/, 'id-ID': /^(\+?62|0[1-9])[\s|\d]+$/, 'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/, - 'ja-JP': /^(\+?81|0)\d{1,4}[ \-]?\d{1,4}[ \-]?\d{4}$/, + 'ja-JP': /^(\+?81|0)[789]0[ \-]?[1-9]\d{2}[ \-]?\d{5}$/, '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}$/, diff --git a/test/validators.js b/test/validators.js index bde1c3b9f..296631722 100644 --- a/test/validators.js +++ b/test/validators.js @@ -1,4 +1,4 @@ -var validator = require('../index'), +var validator = require('../index'), format = require('util').format, assert = require('assert'), path = require('path'), @@ -3476,6 +3476,7 @@ describe('Validators', function () { '358505557171', '04412345', '0457 123 45 67', + '+358457 123 45 67', '+358 50 555 7171', ], @@ -3551,19 +3552,9 @@ describe('Validators', function () { { locale: 'ja-JP', valid: [ - '0312345678', - '0721234567', '09012345688', - '06 1234 5678', - '072 123 4567', - '0729 12 3456', - '07296 1 2345', - '072961 2345', - '090 1234 5678', - '03-1234-5678', - '+81312345678', - '+816-1234-5678', - '+8190-1234-5678', + '090 123 45678', + '+8190-123-45678', ], invalid: [ '12345', @@ -3574,6 +3565,17 @@ describe('Validators', function () { '0 1234 5689', '16 1234 5689', '03_1234_5689', + '0312345678', + '0721234567', + '08002345678' + '06 1234 5678', + '072 123 4567', + '0729 12 3456', + '07296 1 2345', + '072961 2345', + '03-1234-5678', + '+81312345678', + '+816-1234-5678', ], }, { From 13f3d6ffab3cc2f49c2541733f6ba8de982b3c13 Mon Sep 17 00:00:00 2001 From: PuHsiu <_@m.puhsiu.cc> Date: Wed, 25 Oct 2017 11:08:43 +0800 Subject: [PATCH 2/3] Patch the missing comma in test case. --- test/validators.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/validators.js b/test/validators.js index 296631722..a47e0be96 100644 --- a/test/validators.js +++ b/test/validators.js @@ -3476,7 +3476,6 @@ describe('Validators', function () { '358505557171', '04412345', '0457 123 45 67', - '+358457 123 45 67', '+358 50 555 7171', ], @@ -3567,7 +3566,7 @@ describe('Validators', function () { '03_1234_5689', '0312345678', '0721234567', - '08002345678' + '08002345678', '06 1234 5678', '072 123 4567', '0729 12 3456', From fd80b1541d40a7172053354b9a815e8574deb4b8 Mon Sep 17 00:00:00 2001 From: PuHsiu <_@m.puhsiu.cc> Date: Wed, 25 Oct 2017 11:22:10 +0800 Subject: [PATCH 3/3] Remove U+FEFF from the begin of file. orz --- test/validators.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/validators.js b/test/validators.js index a47e0be96..a511dd79f 100644 --- a/test/validators.js +++ b/test/validators.js @@ -1,4 +1,4 @@ -var validator = require('../index'), +var validator = require('../index'), format = require('util').format, assert = require('assert'), path = require('path'),