ztxkutils 2.0.7 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,24 @@
1
+ /**
2
+ * value 当前值
3
+ * record 当前行数据
4
+ * index 当前第几行
5
+ * title 当前列标题
6
+ */
7
+ declare type validateFn = (value: any, record: any, index: number, title: string) => any;
1
8
  interface IColumns {
2
9
  dataIndex: string;
3
10
  title: string;
4
- required?: boolean;
11
+ required?: boolean | string;
5
12
  validate?: {
6
13
  pattern: any;
7
14
  message?: string;
8
- } | any;
15
+ } | validateFn;
9
16
  [props: string]: any;
10
17
  }
11
18
  /**
12
19
  * @description 表格验证相关操作
13
20
  */
14
21
  declare function useTableValidate(records: any, columns: IColumns[], tableName?: string): {
15
- tableValidate: () => Promise<any>;
22
+ tableValidate: () => Promise<void>;
16
23
  };
17
24
  export default useTableValidate;
package/dist/hooks.js CHANGED
@@ -112,8 +112,10 @@ function useTableValidate(records, columns, tableName) {
112
112
  value = item[key];
113
113
  if (!validate) return [3 /*break*/, 7];
114
114
  if (!(typeof validate === 'function')) return [3 /*break*/, 4];
115
- return [4 /*yield*/, validate(value, item)];
116
- case 3: return [2 /*return*/, _c.sent()];
115
+ return [4 /*yield*/, validate(value, item, i + 1, title)];
116
+ case 3:
117
+ _c.sent();
118
+ return [3 /*break*/, 6];
117
119
  case 4:
118
120
  if (!!((_b = validate.pattern) === null || _b === void 0 ? void 0 : _b.test(value))) return [3 /*break*/, 6];
119
121
  return [4 /*yield*/, Promise.reject({
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export { c as authority } from './authority-17b7fde2.js';
2
2
  export { d as dataModel } from './dataModel-1fbaff40.js';
3
3
  export { t as tools } from './tools-49b33116.js';
4
- export { v as validate } from './validate-743d8f98.js';
4
+ export { v as validate } from './validate-cc61f65f.js';
5
5
  export { r as request } from './request-74ca7860.js';
6
6
  export { r as reqUrl } from './reqUrl-68c864fb.js';
7
7
  import './tslib.es6-b9033aad.js';
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @description 常用正则表达式
3
+ */
4
+ var validate = {
5
+ /**
6
+ * @description 长度验证,最小长度字符,0-200个字符
7
+ */
8
+ smallLenValidate: /^(?:\s*)[\s\S]{0,200}(?:\s*)$/,
9
+ /**
10
+ * @description 长度验证,中等长度字符,0-400个字符
11
+ */
12
+ middleLenValidate: /^(?:\s*)[\s\S]{0,400}(?:\s*)$/,
13
+ /**
14
+ * @description 长度验证,最大长度字符,0-600个字符
15
+ */
16
+ largeLenValidate: /^(?:\s*)[\s\S]{0,600}(?:\s*)$/,
17
+ /**
18
+ * @description 电话号码验证
19
+ */
20
+ phoneValidate: /^1[0-9]{10}$/,
21
+ /**
22
+ * @description 身份证验证
23
+ * 18位 最后一位可以是X x
24
+ */
25
+ idCardValidate: /^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
26
+ /**
27
+ * @description 邮箱验证
28
+ */
29
+ emailValidate: /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
30
+ /**
31
+ * @description 密码验证
32
+ */
33
+ passwordValidate: /^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&*]+$)([a-zA-Z\d!@#$%^&*]+){9,128}$/,
34
+ };
35
+ var commonMessage = {
36
+ smallLenMessage: function (type) {
37
+ if (type === void 0) { type = ''; }
38
+ return type + "\u8D85\u8FC7\u6700\u5927\u5B57\u7B26\u957F\u5EA6200";
39
+ },
40
+ middleLenMessage: function (type) {
41
+ if (type === void 0) { type = ''; }
42
+ return type + "\u8D85\u8FC7\u6700\u5927\u5B57\u7B26\u957F\u5EA6400";
43
+ },
44
+ largeLenMessage: function (type) {
45
+ if (type === void 0) { type = ''; }
46
+ return type + "\u8D85\u8FC7\u6700\u5927\u5B57\u7B26\u957F\u5EA6600";
47
+ },
48
+ phoneMessage: '请输入正确的手机号',
49
+ idCardMessage: '请输入正确的身份证',
50
+ emailMessage: '请输入正确的邮箱',
51
+ passwordMessage: '由9-128位的字母+数字,字母+特殊字符,数字+特殊字符组成',
52
+ };
53
+
54
+ var validate$1 = /*#__PURE__*/Object.freeze({
55
+ __proto__: null,
56
+ validate: validate,
57
+ commonMessage: commonMessage
58
+ });
59
+
60
+ export { validate as a, commonMessage as c, validate$1 as v };
package/dist/validate.js CHANGED
@@ -1 +1 @@
1
- export { c as commonMessage, a as validate } from './validate-743d8f98.js';
1
+ export { c as commonMessage, a as validate } from './validate-cc61f65f.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkutils",
3
- "version": "2.0.7",
3
+ "version": "2.1.1",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",