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
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
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
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
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
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
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
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
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
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
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:
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:
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:
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:
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:
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
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
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
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
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
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
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