From 17e8d2bb6d351416095c993616adcdcd3b3731ea Mon Sep 17 00:00:00 2001 From: Cai Zhijiang Date: Mon, 6 Feb 2023 09:47:21 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E5=88=86=E5=9F=8E=E5=B8=82=E6=9C=894?= =?UTF-8?q?=E4=BD=8D=E5=8C=BA=E5=8F=B7+8=E4=BD=8D=E5=8F=B7=E7=A0=81=20(#69?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- validator/validator.go | 2 +- validator/validator_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/validator/validator.go b/validator/validator.go index e1dbb50..2127571 100644 --- a/validator/validator.go +++ b/validator/validator.go @@ -25,7 +25,7 @@ var ( chineseMobileMatcher *regexp.Regexp = regexp.MustCompile(`^1(?:3\d|4[4-9]|5[0-35-9]|6[67]|7[013-8]|8\d|9\d)\d{8}$`) chineseIdMatcher *regexp.Regexp = regexp.MustCompile(`^[1-9]\d{5}(18|19|20|21|22)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$`) chineseMatcher *regexp.Regexp = regexp.MustCompile("[\u4e00-\u9fa5]") - chinesePhoneMatcher *regexp.Regexp = regexp.MustCompile(`\d{3}-\d{8}|\d{4}-\d{7}`) + chinesePhoneMatcher *regexp.Regexp = regexp.MustCompile(`\d{3}-\d{8}|\d{4}-\d{7}|\d{4}-\d{8}`) creditCardMatcher *regexp.Regexp = regexp.MustCompile(`^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\\d{3})\\d{11}|6[27][0-9]{14})$`) base64Matcher *regexp.Regexp = regexp.MustCompile(`^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=|[A-Za-z0-9+\\/]{4})$`) ) diff --git a/validator/validator_test.go b/validator/validator_test.go index 6a237a5..34ba876 100644 --- a/validator/validator_test.go +++ b/validator/validator_test.go @@ -208,6 +208,7 @@ func TestIsChinesePhone(t *testing.T) { assert.Equal(true, IsChinesePhone("010-32116675")) assert.Equal(true, IsChinesePhone("0464-8756213")) + assert.Equal(true, IsChinesePhone("0731-82251545")) //长沙晚报电话 assert.Equal(false, IsChinesePhone("123-87562")) }