From b1d5a6a51dff421aaa061e132a705fd91ac8c579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E9=87=91=E9=94=8B?= Date: Thu, 19 Nov 2020 15:05:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/divide.js.html | 2 +- docs/formatBankCard.js.html | 2 +- docs/formatMoney.js.html | 2 +- docs/index.html | 2 +- docs/index.js.html | 2 +- docs/isBankCard.js.html | 2 +- docs/isBusinessLicense.js.html | 2 +- docs/isChinese.js.html | 2 +- docs/isEmail.js.html | 2 +- docs/isIPv4.js.html | 2 +- docs/isIPv6.js.html | 2 +- docs/isIdCard.js.html | 2 +- docs/isMobile.js.html | 2 +- docs/isPassport.js.html | 2 +- docs/isPassword.js.html | 111 ++------------------------------ docs/isPostcode.js.html | 2 +- docs/isQQ.js.html | 2 +- docs/isSocialCreditCode.js.html | 2 +- docs/isTelephone.js.html | 2 +- docs/isUrl.js.html | 2 +- docs/isVehicle.js.html | 2 +- docs/isWX.js.html | 2 +- docs/minus.js.html | 2 +- docs/module-Debug.html | 2 +- docs/module-Math.html | 2 +- docs/module-Processor.html | 2 +- docs/module-Validator.html | 14 ++-- docs/module-processor.html | 2 +- docs/module-validator.html | 14 ++-- docs/numberToChinese.js.html | 2 +- docs/plus.js.html | 2 +- docs/replaceChar.js.html | 2 +- docs/round.js.html | 2 +- docs/times.js.html | 2 +- docs/validatePassword.js.html | 2 +- src/isPassword.js | 3 +- 36 files changed, 58 insertions(+), 148 deletions(-) diff --git a/docs/divide.js.html b/docs/divide.js.html index 49b7f26b..57948a9b 100644 --- a/docs/divide.js.html +++ b/docs/divide.js.html @@ -106,7 +106,7 @@

divide.js


diff --git a/docs/formatBankCard.js.html b/docs/formatBankCard.js.html index 17eeefc4..882d3eb7 100644 --- a/docs/formatBankCard.js.html +++ b/docs/formatBankCard.js.html @@ -109,7 +109,7 @@

formatBankCard.js


diff --git a/docs/formatMoney.js.html b/docs/formatMoney.js.html index fe557856..fee0f02f 100644 --- a/docs/formatMoney.js.html +++ b/docs/formatMoney.js.html @@ -200,7 +200,7 @@

formatMoney.js


diff --git a/docs/index.html b/docs/index.html index 9ddf551a..1da136fe 100644 --- a/docs/index.html +++ b/docs/index.html @@ -172,7 +172,7 @@

精选第三方工具库


diff --git a/docs/index.js.html b/docs/index.js.html index b2789408..90a902b8 100644 --- a/docs/index.js.html +++ b/docs/index.js.html @@ -126,7 +126,7 @@

index.js


diff --git a/docs/isBankCard.js.html b/docs/isBankCard.js.html index 41c2d194..4882cc5a 100644 --- a/docs/isBankCard.js.html +++ b/docs/isBankCard.js.html @@ -111,7 +111,7 @@

isBankCard.js


diff --git a/docs/isBusinessLicense.js.html b/docs/isBusinessLicense.js.html index 46090aa0..73cc62f4 100644 --- a/docs/isBusinessLicense.js.html +++ b/docs/isBusinessLicense.js.html @@ -152,7 +152,7 @@

isBusinessLicense.js


diff --git a/docs/isChinese.js.html b/docs/isChinese.js.html index 54013b1c..c6ead8f2 100644 --- a/docs/isChinese.js.html +++ b/docs/isChinese.js.html @@ -157,7 +157,7 @@

isChinese.js


diff --git a/docs/isEmail.js.html b/docs/isEmail.js.html index 371c3947..152e503c 100644 --- a/docs/isEmail.js.html +++ b/docs/isEmail.js.html @@ -94,7 +94,7 @@

isEmail.js


diff --git a/docs/isIPv4.js.html b/docs/isIPv4.js.html index 166f0a81..d86a5c76 100644 --- a/docs/isIPv4.js.html +++ b/docs/isIPv4.js.html @@ -100,7 +100,7 @@

isIPv4.js


diff --git a/docs/isIPv6.js.html b/docs/isIPv6.js.html index 81f5146a..7fff5f10 100644 --- a/docs/isIPv6.js.html +++ b/docs/isIPv6.js.html @@ -125,7 +125,7 @@

isIPv6.js


diff --git a/docs/isIdCard.js.html b/docs/isIdCard.js.html index e04fd692..e31c9417 100644 --- a/docs/isIdCard.js.html +++ b/docs/isIdCard.js.html @@ -100,7 +100,7 @@

isIdCard.js


diff --git a/docs/isMobile.js.html b/docs/isMobile.js.html index 2f3098cf..6bbabd38 100644 --- a/docs/isMobile.js.html +++ b/docs/isMobile.js.html @@ -94,7 +94,7 @@

isMobile.js


diff --git a/docs/isPassport.js.html b/docs/isPassport.js.html index ab30325e..5458d038 100644 --- a/docs/isPassport.js.html +++ b/docs/isPassport.js.html @@ -96,7 +96,7 @@

isPassport.js


diff --git a/docs/isPassword.js.html b/docs/isPassword.js.html index 0ba5f7af..7727c056 100644 --- a/docs/isPassword.js.html +++ b/docs/isPassword.js.html @@ -56,91 +56,18 @@

isPassword.js

-
const regNumber = /[\d]/;
-const regLetter = /[a-z]/i;
-const regLowerCaseLetter = /[a-z]/;
-const regUpperCaseLetter = /[A-Z]/;
-const regAllNumberAndLetter = /[\d|a-z]/ig;
-
-// 是否包含数字
-function hasNumber(val) {
-  return regNumber.test(val);
-}
-
-// 是否包含小写字母
-function hasLowerCaseLetter(val) {
-  return regLowerCaseLetter.test(val);
-}
-
-// 是否包含大写字母
-function hasUpperCaseLetter(val) {
-  return regUpperCaseLetter.test(val);
-}
-
-// 是否包含大写字母
-function hasLetter(val) {
-  return regLetter.test(val);
-}
-
-// 是否为十六进制
-function hasHex(val) {
-  return val.indexOf('\\x') > -1 || val.indexOf('\\u') > -1;
-}
-
-// 是否包含特殊字符
-function hasSpecial(val, chars = '') {
-  if (!chars) {
-    return false;
-  }
-
-  const specialChars = val.replace(regAllNumberAndLetter, '');
-  const regChars = hasHex(chars) ? new RegExp(`[${chars}]`) : null;
-
-  if (regChars) {
-    return regChars.test(specialChars);
-  }
-
-  let ret = false;
-  specialChars.split('').some((charItem) => {
-    if (chars.indexOf(charItem) > -1) {
-      ret = true;
-    }
-    return ret;
-  });
-  return ret;
-}
-
-// 是否包含非法字符
-function hasDisabled(val, chars = '') {
-  const specialChars = val.replace(regAllNumberAndLetter, '');
-
-  if (!chars && specialChars) {
-    return true;
-  }
-
-  const regChars = hasHex(chars) ? new RegExp(`[^${chars}]`) : null;
-  if (regChars) {
-    return regChars.test(specialChars);
-  }
-  let ret = false;
-  specialChars.split('').some((charItem) => {
-    if (chars.indexOf(charItem) === -1) {
-      ret = true;
-    }
-    return ret;
-  });
-  return ret;
-}
+            
import validatePassword from './validatePassword';
 
 /**
  * 检测值是否符合密码强度
- * 注意该校验只校验是否存在不同字符(大小写字母、数字、特殊符号),不判断长度
+ * <p><strong>注意:该校验只校验是否存在不同字符(大小写字母、数字、特殊符号),不判断长度。</strong></p>
+ * <p><i>如果需要更细致的验证,请使用 <a href="#.validatePassword">validatePassword</a></i></p>
  * 
  * @see {@link https://baike.baidu.com/item/ASCII#3|ASCII}
  * @static
  * @alias module:Validator.isPassword
  * @since 1.1.0
- * @deprecated 将在下次大版本更新后废弃,请使用 validatePassword
+ * @requires module:Validator.validatePassword
  * @param {string} value 要检测的值
  * @param {object} [options] 配置项
  * @param {number} [options.level=2] 密码强度 1-包含一种字符 2-包含两种字符 3-包含三种字符。(大写字母、小写字母、数字、特殊字符)
@@ -176,33 +103,7 @@ 

isPassword.js

ignoreCase = false, special = "\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E" } = {}) { - if (typeof value !== 'string' || !value) { - return false; - } - - let currentLevel = 0; - - if (hasNumber(value)) { - currentLevel += 1; - } - - if (ignoreCase) { // 不区分大小写 - if (hasLetter(value)) { - currentLevel += 1; - } - } else { // 区分大小写 - if (hasLowerCaseLetter(value)) { - currentLevel += 1; - } - if (hasUpperCaseLetter(value)) { - currentLevel += 1; - } - } - - if (hasSpecial(value, special)) { - currentLevel += 1; - } - return currentLevel >= level && !hasDisabled(value, special); + return validatePassword(value, { level, ignoreCase, special }).validated; } export default isPassword;
@@ -219,7 +120,7 @@

isPassword.js


- Documentation generated by JSDoc 3.6.3 on Fri Nov 13 2020 14:17:28 GMT+0800 (GMT+08:00) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Thu Nov 19 2020 15:04:47 GMT+0800 (GMT+08:00) using the docdash theme.
diff --git a/docs/isPostcode.js.html b/docs/isPostcode.js.html index 5f01b45e..ad789452 100644 --- a/docs/isPostcode.js.html +++ b/docs/isPostcode.js.html @@ -94,7 +94,7 @@

isPostcode.js


- Documentation generated by JSDoc 3.6.3 on Fri Nov 13 2020 14:17:28 GMT+0800 (GMT+08:00) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Thu Nov 19 2020 15:04:47 GMT+0800 (GMT+08:00) using the docdash theme.
diff --git a/docs/isQQ.js.html b/docs/isQQ.js.html index e30886b4..59f7934c 100644 --- a/docs/isQQ.js.html +++ b/docs/isQQ.js.html @@ -94,7 +94,7 @@

isQQ.js


- Documentation generated by JSDoc 3.6.3 on Fri Nov 13 2020 14:17:28 GMT+0800 (GMT+08:00) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Thu Nov 19 2020 15:04:47 GMT+0800 (GMT+08:00) using the docdash theme.
diff --git a/docs/isSocialCreditCode.js.html b/docs/isSocialCreditCode.js.html index 87319322..c1b6097d 100644 --- a/docs/isSocialCreditCode.js.html +++ b/docs/isSocialCreditCode.js.html @@ -175,7 +175,7 @@

isSocialCreditCode.js


- Documentation generated by JSDoc 3.6.3 on Fri Nov 13 2020 14:17:28 GMT+0800 (GMT+08:00) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Thu Nov 19 2020 15:04:47 GMT+0800 (GMT+08:00) using the docdash theme.
diff --git a/docs/isTelephone.js.html b/docs/isTelephone.js.html index da366b4c..18387d43 100644 --- a/docs/isTelephone.js.html +++ b/docs/isTelephone.js.html @@ -100,7 +100,7 @@

isTelephone.js


- Documentation generated by JSDoc 3.6.3 on Fri Nov 13 2020 14:17:28 GMT+0800 (GMT+08:00) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Thu Nov 19 2020 15:04:47 GMT+0800 (GMT+08:00) using the docdash theme.
diff --git a/docs/isUrl.js.html b/docs/isUrl.js.html index bec58546..10e3316c 100644 --- a/docs/isUrl.js.html +++ b/docs/isUrl.js.html @@ -105,7 +105,7 @@

isUrl.js


- Documentation generated by JSDoc 3.6.3 on Fri Nov 13 2020 14:17:28 GMT+0800 (GMT+08:00) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Thu Nov 19 2020 15:04:47 GMT+0800 (GMT+08:00) using the docdash theme.
diff --git a/docs/isVehicle.js.html b/docs/isVehicle.js.html index 1b6e62fa..860fbfa5 100644 --- a/docs/isVehicle.js.html +++ b/docs/isVehicle.js.html @@ -104,7 +104,7 @@

isVehicle.js


- Documentation generated by JSDoc 3.6.3 on Fri Nov 13 2020 14:17:28 GMT+0800 (GMT+08:00) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Thu Nov 19 2020 15:04:47 GMT+0800 (GMT+08:00) using the docdash theme.
diff --git a/docs/isWX.js.html b/docs/isWX.js.html index af56725a..644f4def 100644 --- a/docs/isWX.js.html +++ b/docs/isWX.js.html @@ -94,7 +94,7 @@

isWX.js


- Documentation generated by JSDoc 3.6.3 on Fri Nov 13 2020 14:17:28 GMT+0800 (GMT+08:00) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Thu Nov 19 2020 15:04:47 GMT+0800 (GMT+08:00) using the docdash theme.
diff --git a/docs/minus.js.html b/docs/minus.js.html index 32a564c4..54664e53 100644 --- a/docs/minus.js.html +++ b/docs/minus.js.html @@ -102,7 +102,7 @@

minus.js


- Documentation generated by JSDoc 3.6.3 on Fri Nov 13 2020 14:17:28 GMT+0800 (GMT+08:00) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Thu Nov 19 2020 15:04:47 GMT+0800 (GMT+08:00) using the docdash theme.
diff --git a/docs/module-Debug.html b/docs/module-Debug.html index eaa16b38..4307087b 100644 --- a/docs/module-Debug.html +++ b/docs/module-Debug.html @@ -190,7 +190,7 @@

Debug


- Documentation generated by JSDoc 3.6.3 on Fri Nov 13 2020 14:17:28 GMT+0800 (GMT+08:00) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Thu Nov 19 2020 15:04:47 GMT+0800 (GMT+08:00) using the docdash theme.
diff --git a/docs/module-Math.html b/docs/module-Math.html index beb5af3d..67fffcbc 100644 --- a/docs/module-Math.html +++ b/docs/module-Math.html @@ -1427,7 +1427,7 @@
Returns:

- Documentation generated by JSDoc 3.6.3 on Fri Nov 13 2020 14:17:28 GMT+0800 (GMT+08:00) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Thu Nov 19 2020 15:04:47 GMT+0800 (GMT+08:00) using the docdash theme.
diff --git a/docs/module-Processor.html b/docs/module-Processor.html index b9dbbe0e..5c01da93 100644 --- a/docs/module-Processor.html +++ b/docs/module-Processor.html @@ -2001,7 +2001,7 @@
Returns:

- Documentation generated by JSDoc 3.6.3 on Fri Nov 13 2020 14:17:28 GMT+0800 (GMT+08:00) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Thu Nov 19 2020 15:04:47 GMT+0800 (GMT+08:00) using the docdash theme.
diff --git a/docs/module-Validator.html b/docs/module-Validator.html index 9f3f41a5..166a6a48 100644 --- a/docs/module-Validator.html +++ b/docs/module-Validator.html @@ -2148,7 +2148,7 @@

(static) i
Source:
@@ -2170,8 +2170,6 @@

(static) i -
Deprecated:
  • 将在下次大版本更新后废弃,请使用 validatePassword
- @@ -2201,7 +2199,8 @@

(static) i
检测值是否符合密码强度 -注意该校验只校验是否存在不同字符(大小写字母、数字、特殊符号),不判断长度 +

注意:该校验只校验是否存在不同字符(大小写字母、数字、特殊符号),不判断长度。

+

如果需要更细致的验证,请使用 validatePassword

@@ -2480,6 +2479,11 @@

Properties
+
Requires:
+ + @@ -4302,7 +4306,7 @@
Returns:

- Documentation generated by JSDoc 3.6.3 on Fri Nov 13 2020 14:17:28 GMT+0800 (GMT+08:00) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Thu Nov 19 2020 15:04:47 GMT+0800 (GMT+08:00) using the docdash theme.
diff --git a/docs/module-processor.html b/docs/module-processor.html index b9dbbe0e..5c01da93 100644 --- a/docs/module-processor.html +++ b/docs/module-processor.html @@ -2001,7 +2001,7 @@
Returns:

- Documentation generated by JSDoc 3.6.3 on Fri Nov 13 2020 14:17:28 GMT+0800 (GMT+08:00) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Thu Nov 19 2020 15:04:47 GMT+0800 (GMT+08:00) using the docdash theme.
diff --git a/docs/module-validator.html b/docs/module-validator.html index 9f3f41a5..166a6a48 100644 --- a/docs/module-validator.html +++ b/docs/module-validator.html @@ -2148,7 +2148,7 @@

(static) i
Source:
@@ -2170,8 +2170,6 @@

(static) i -
Deprecated:
  • 将在下次大版本更新后废弃,请使用 validatePassword
- @@ -2201,7 +2199,8 @@

(static) i
检测值是否符合密码强度 -注意该校验只校验是否存在不同字符(大小写字母、数字、特殊符号),不判断长度 +

注意:该校验只校验是否存在不同字符(大小写字母、数字、特殊符号),不判断长度。

+

如果需要更细致的验证,请使用 validatePassword

@@ -2480,6 +2479,11 @@

Properties
+
Requires:
+ + @@ -4302,7 +4306,7 @@
Returns:

- Documentation generated by JSDoc 3.6.3 on Fri Nov 13 2020 14:17:28 GMT+0800 (GMT+08:00) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Thu Nov 19 2020 15:04:47 GMT+0800 (GMT+08:00) using the docdash theme.
diff --git a/docs/numberToChinese.js.html b/docs/numberToChinese.js.html index b2d6d687..5ad9ff76 100644 --- a/docs/numberToChinese.js.html +++ b/docs/numberToChinese.js.html @@ -295,7 +295,7 @@

numberToChinese.js


- Documentation generated by JSDoc 3.6.3 on Fri Nov 13 2020 14:17:28 GMT+0800 (GMT+08:00) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Thu Nov 19 2020 15:04:47 GMT+0800 (GMT+08:00) using the docdash theme.
diff --git a/docs/plus.js.html b/docs/plus.js.html index c4efc387..27e2d814 100644 --- a/docs/plus.js.html +++ b/docs/plus.js.html @@ -102,7 +102,7 @@

plus.js


- Documentation generated by JSDoc 3.6.3 on Fri Nov 13 2020 14:17:28 GMT+0800 (GMT+08:00) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Thu Nov 19 2020 15:04:47 GMT+0800 (GMT+08:00) using the docdash theme.
diff --git a/docs/replaceChar.js.html b/docs/replaceChar.js.html index 42311895..0f8b29ed 100644 --- a/docs/replaceChar.js.html +++ b/docs/replaceChar.js.html @@ -150,7 +150,7 @@

replaceChar.js


- Documentation generated by JSDoc 3.6.3 on Fri Nov 13 2020 14:17:28 GMT+0800 (GMT+08:00) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Thu Nov 19 2020 15:04:47 GMT+0800 (GMT+08:00) using the docdash theme.
diff --git a/docs/round.js.html b/docs/round.js.html index e2dc12ed..c9a164c4 100644 --- a/docs/round.js.html +++ b/docs/round.js.html @@ -98,7 +98,7 @@

round.js


- Documentation generated by JSDoc 3.6.3 on Fri Nov 13 2020 14:17:28 GMT+0800 (GMT+08:00) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Thu Nov 19 2020 15:04:47 GMT+0800 (GMT+08:00) using the docdash theme.
diff --git a/docs/times.js.html b/docs/times.js.html index 2ef01f84..90d41d65 100644 --- a/docs/times.js.html +++ b/docs/times.js.html @@ -107,7 +107,7 @@

times.js


- Documentation generated by JSDoc 3.6.3 on Fri Nov 13 2020 14:17:28 GMT+0800 (GMT+08:00) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Thu Nov 19 2020 15:04:47 GMT+0800 (GMT+08:00) using the docdash theme.
diff --git a/docs/validatePassword.js.html b/docs/validatePassword.js.html index a4e97859..46bff0ec 100644 --- a/docs/validatePassword.js.html +++ b/docs/validatePassword.js.html @@ -278,7 +278,7 @@

validatePassword.js


- Documentation generated by JSDoc 3.6.3 on Fri Nov 13 2020 14:17:28 GMT+0800 (GMT+08:00) using the docdash theme. + Documentation generated by JSDoc 3.6.3 on Thu Nov 19 2020 15:04:47 GMT+0800 (GMT+08:00) using the docdash theme.
diff --git a/src/isPassword.js b/src/isPassword.js index b682fad1..864819df 100644 --- a/src/isPassword.js +++ b/src/isPassword.js @@ -2,7 +2,8 @@ import validatePassword from './validatePassword'; /** * 检测值是否符合密码强度 - * 注意该校验只校验是否存在不同字符(大小写字母、数字、特殊符号),不判断长度。如果需要更细致的验证,请使用 `validatePassword` + *

注意:该校验只校验是否存在不同字符(大小写字母、数字、特殊符号),不判断长度。

+ *

如果需要更细致的验证,请使用 validatePassword

* * @see {@link https://baike.baidu.com/item/ASCII#3|ASCII} * @static