ztxkutils 2.10.37 → 2.10.39

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export { c as authority } from './authority-e6bde99f.js';
2
2
  export { d as dataModel } from './dataModel-1fbaff40.js';
3
3
  export { t as tools } from './tools-09a4d620.js';
4
- export { v as validate } from './validate-0010aa8c.js';
4
+ export { v as validate } from './validate-a06e1fa0.js';
5
5
  export { r as request } from './request-8e2b5826.js';
6
6
  export { r as reqUrl } from './reqUrl-787dd9e5.js';
7
7
  import './tslib.es6-35653116.js';
@@ -68,25 +68,51 @@ var commonMessage = {
68
68
  idCardMessage: '请输入正确的身份证',
69
69
  emailMessage: '请输入正确的邮箱',
70
70
  // passwordMessage: '密码由8-16位的字母+数字,字母+特殊字符,数字+特殊字符组成',
71
- passwordMessage: '密码必须包含大小写字母、数字、特殊字符,且不能出现连续数字或字符,不能出现相同字符,且禁止使用用户账号作为密码',
71
+ passwordMessage: '密码必须包含大小写字母、数字、特殊字符且最小长度为8,且不能出现连续数字或字符,不能出现相同字符,且禁止使用用户账号作为密码',
72
72
  spaceMessage: '请勿输入空格',
73
73
  };
74
+ function isConsecutiveChars(char1, char2) {
75
+ var lowerCaseAlphabet = 'abcdefghijklmnopqrstuvwxyz'; // 小写字母
76
+ var upperCaseAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; // 大写字母
77
+ var numeric = '0123456789'; // 数字
78
+ // 找到包含两个字符的字符集
79
+ var alphabet = [lowerCaseAlphabet, upperCaseAlphabet, numeric].find(function (alph) { return alph.includes(char1) && alph.includes(char2); });
80
+ if (!alphabet) {
81
+ return false; // 如果两个字符不在同一字符集中,那么它们不可能连续
82
+ }
83
+ var index1 = alphabet.indexOf(char1);
84
+ var index2 = alphabet.indexOf(char2);
85
+ return Math.abs(index1 - index2) === 1; // 如果两个字符在字符集中的位置相邻,那么它们是连续的
86
+ }
74
87
  function validatePassword(password, username) {
75
88
  // 用正则表达式检查密码基本规则
76
89
  var regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\da-zA-Z]).{8,}$/;
77
90
  if (!regex.test(password)) {
78
91
  return {
79
92
  result: false,
80
- message: '密码中必须包含大小写字母、数字、特殊字符!',
93
+ message: '密码中必须包含大小写字母、数字、特殊字符,且长度必须大于8个字符!',
81
94
  };
82
95
  }
83
- // 检查密码中是否有连续的字母或数字
96
+ // 检查密码中是否有连续的字母或数字 连续超过三次
97
+ var count = 0;
98
+ var startChart = 0;
84
99
  for (var i = 0; i < password.length - 1; i++) {
85
- if (Math.abs(password.charCodeAt(i) - password.charCodeAt(i + 1)) === 1) {
86
- return {
87
- result: false,
88
- message: '密码中有连续的字母或数字!',
89
- };
100
+ if (isConsecutiveChars(password[i], password[i + 1])) {
101
+ if (count === 0) {
102
+ startChart = i;
103
+ }
104
+ count++;
105
+ if (count >= 2) {
106
+ // 密码中不应含有连续的字母或数字
107
+ return {
108
+ result: false,
109
+ message: "\u4ECE\u7B2C" + (startChart + 1) + "\u4E2A\u5B57\u7B26\u5F00\u59CB\uFF0C\u6709\u8FDE\u7EED\u8D85\u8FC7\u4E09\u4F4D\u7684\u5B57\u6BCD\u6216\u6570\u5B57!",
110
+ };
111
+ }
112
+ }
113
+ else {
114
+ count = 0;
115
+ startChart = 0;
90
116
  }
91
117
  }
92
118
  // 检查密码中是否有相同的字符
package/dist/validate.js CHANGED
@@ -1 +1 @@
1
- export { c as commonMessage, b as validate, a as validatePassword } from './validate-0010aa8c.js';
1
+ export { c as commonMessage, b as validate, a as validatePassword } from './validate-a06e1fa0.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkutils",
3
- "version": "2.10.37",
3
+ "version": "2.10.39",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",