tools-min-ns 1.8.1 → 1.9.0

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.
package/README.md CHANGED
@@ -5,6 +5,10 @@ cnpm i tools-min-ns --save
5
5
  ```
6
6
 
7
7
  # updates
8
+ ## v1.9.0
9
+
10
+ > CheckUtil getFormItemRules 新增required参数
11
+
8
12
  ## v1.8.1
9
13
 
10
14
  > TreeUtil 修复getItemPathByTree
@@ -103,6 +103,7 @@ declare namespace CheckUtil {
103
103
  */
104
104
  function getFormItemRules<T>(type: StrType, options?: {
105
105
  label?: string;
106
+ required?: boolean;
106
107
  errMsg?: string;
107
108
  _validator?: any;
108
109
  }): T[];
@@ -113,6 +113,37 @@ var __generator = this && this.__generator || function (thisArg, body) {
113
113
  };
114
114
  }
115
115
  };
116
+ var __read = this && this.__read || function (o, n) {
117
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
118
+ if (!m) return o;
119
+ var i = m.call(o),
120
+ r,
121
+ ar = [],
122
+ e;
123
+ try {
124
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
125
+ } catch (error) {
126
+ e = {
127
+ error: error
128
+ };
129
+ } finally {
130
+ try {
131
+ if (r && !r.done && (m = i["return"])) m.call(i);
132
+ } finally {
133
+ if (e) throw e.error;
134
+ }
135
+ }
136
+ return ar;
137
+ };
138
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
139
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
140
+ if (ar || !(i in from)) {
141
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
142
+ ar[i] = from[i];
143
+ }
144
+ }
145
+ return to.concat(ar || Array.prototype.slice.call(from));
146
+ };
116
147
  /**
117
148
  * 校验工具
118
149
  * @description
@@ -457,7 +488,11 @@ var CheckUtil;
457
488
  */
458
489
  function getFormItemRules(type, options) {
459
490
  var _this = this;
460
- return [{
491
+ var msg = (options === null || options === void 0 ? void 0 : options.label) || STR_TYPE[type];
492
+ return __spreadArray(__spreadArray([], __read((options === null || options === void 0 ? void 0 : options.required) === undefined || (options === null || options === void 0 ? void 0 : options.required) ? [{
493
+ required: true,
494
+ message: "".concat(msg, "\u4E0D\u80FD\u4E3A\u7A7A")
495
+ }] : []), false), [{
461
496
  validator: function validator(_, value, c) {
462
497
  return __awaiter(_this, void 0, void 0, function () {
463
498
  var _a;
@@ -465,16 +500,16 @@ var CheckUtil;
465
500
  (_a = options === null || options === void 0 ? void 0 : options._validator) === null || _a === void 0 ? void 0 : _a.call(options, _, value, c);
466
501
  if (!value || CheckUtil.checkAny(value, type)) return [2 /*return*/, Promise.resolve()];
467
502
  if (type === 'LOGIN_NAME') {
468
- return [2 /*return*/, Promise.reject(new Error((options === null || options === void 0 ? void 0 : options.errMsg) || "".concat((options === null || options === void 0 ? void 0 : options.label) || STR_TYPE[type], "\u53EA\u5305\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\u6216\u51CF\u53F7\uFF1B\u9996\u5B57\u6BCD\u5FC5\u987B\u4E3A\u5B57\u6BCD\uFF1B\u957F\u5EA6\u4E3A6-18\u4E2A\u5B57\u7B26\uFF1B\u4E0D\u80FD\u5305\u542B\u7279\u6B8A\u5B57\u7B26")))];
503
+ return [2 /*return*/, Promise.reject(new Error((options === null || options === void 0 ? void 0 : options.errMsg) || "".concat(msg, "\u53EA\u5305\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\u6216\u51CF\u53F7\uFF1B\u9996\u5B57\u6BCD\u5FC5\u987B\u4E3A\u5B57\u6BCD\uFF1B\u957F\u5EA6\u4E3A6-18\u4E2A\u5B57\u7B26\uFF1B\u4E0D\u80FD\u5305\u542B\u7279\u6B8A\u5B57\u7B26")))];
469
504
  }
470
505
  if (type === 'PASSWORD') {
471
- return [2 /*return*/, Promise.reject(new Error((options === null || options === void 0 ? void 0 : options.errMsg) || "".concat((options === null || options === void 0 ? void 0 : options.label) || STR_TYPE[type], "\u5FC5\u987B\u957F\u5EA6\u8D85\u8FC78-15\u4F4D\uFF0C\u5305\u62EC\u5927\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u7279\u6B8A\u7B26\u53F7")))];
506
+ return [2 /*return*/, Promise.reject(new Error((options === null || options === void 0 ? void 0 : options.errMsg) || "".concat(msg, "\u5FC5\u987B\u957F\u5EA6\u8D85\u8FC78-15\u4F4D\uFF0C\u5305\u62EC\u5927\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u7279\u6B8A\u7B26\u53F7")))];
472
507
  }
473
- return [2 /*return*/, Promise.reject(new Error((options === null || options === void 0 ? void 0 : options.errMsg) || "\u683C\u5F0F\u9519\u8BEF\uFF0C\u8BF7\u8F93\u5165\u6B63\u786E\u7684".concat((options === null || options === void 0 ? void 0 : options.label) || STR_TYPE[type], "\uFF01")))];
508
+ return [2 /*return*/, Promise.reject(new Error((options === null || options === void 0 ? void 0 : options.errMsg) || "\u683C\u5F0F\u9519\u8BEF\uFF0C\u8BF7\u8F93\u5165\u6B63\u786E\u7684".concat(msg, "\uFF01")))];
474
509
  });
475
510
  });
476
511
  }
477
- }];
512
+ }], false);
478
513
  }
479
514
  CheckUtil.getFormItemRules = getFormItemRules;
480
515
  })(CheckUtil || (CheckUtil = {}));
@@ -103,6 +103,7 @@ declare namespace CheckUtil {
103
103
  */
104
104
  function getFormItemRules<T>(type: StrType, options?: {
105
105
  label?: string;
106
+ required?: boolean;
106
107
  errMsg?: string;
107
108
  _validator?: any;
108
109
  }): T[];
@@ -115,6 +115,37 @@ var __generator = this && this.__generator || function (thisArg, body) {
115
115
  };
116
116
  }
117
117
  };
118
+ var __read = this && this.__read || function (o, n) {
119
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
120
+ if (!m) return o;
121
+ var i = m.call(o),
122
+ r,
123
+ ar = [],
124
+ e;
125
+ try {
126
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
127
+ } catch (error) {
128
+ e = {
129
+ error: error
130
+ };
131
+ } finally {
132
+ try {
133
+ if (r && !r.done && (m = i["return"])) m.call(i);
134
+ } finally {
135
+ if (e) throw e.error;
136
+ }
137
+ }
138
+ return ar;
139
+ };
140
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
141
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
142
+ if (ar || !(i in from)) {
143
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
144
+ ar[i] = from[i];
145
+ }
146
+ }
147
+ return to.concat(ar || Array.prototype.slice.call(from));
148
+ };
118
149
  var __importDefault = this && this.__importDefault || function (mod) {
119
150
  return mod && mod.__esModule ? mod : {
120
151
  "default": mod
@@ -467,7 +498,11 @@ var CheckUtil;
467
498
  */
468
499
  function getFormItemRules(type, options) {
469
500
  var _this = this;
470
- return [{
501
+ var msg = (options === null || options === void 0 ? void 0 : options.label) || common_1.STR_TYPE[type];
502
+ return __spreadArray(__spreadArray([], __read((options === null || options === void 0 ? void 0 : options.required) === undefined || (options === null || options === void 0 ? void 0 : options.required) ? [{
503
+ required: true,
504
+ message: "".concat(msg, "\u4E0D\u80FD\u4E3A\u7A7A")
505
+ }] : []), false), [{
471
506
  validator: function validator(_, value, c) {
472
507
  return __awaiter(_this, void 0, void 0, function () {
473
508
  var _a;
@@ -475,16 +510,16 @@ var CheckUtil;
475
510
  (_a = options === null || options === void 0 ? void 0 : options._validator) === null || _a === void 0 ? void 0 : _a.call(options, _, value, c);
476
511
  if (!value || CheckUtil.checkAny(value, type)) return [2 /*return*/, Promise.resolve()];
477
512
  if (type === 'LOGIN_NAME') {
478
- return [2 /*return*/, Promise.reject(new Error((options === null || options === void 0 ? void 0 : options.errMsg) || "".concat((options === null || options === void 0 ? void 0 : options.label) || common_1.STR_TYPE[type], "\u53EA\u5305\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\u6216\u51CF\u53F7\uFF1B\u9996\u5B57\u6BCD\u5FC5\u987B\u4E3A\u5B57\u6BCD\uFF1B\u957F\u5EA6\u4E3A6-18\u4E2A\u5B57\u7B26\uFF1B\u4E0D\u80FD\u5305\u542B\u7279\u6B8A\u5B57\u7B26")))];
513
+ return [2 /*return*/, Promise.reject(new Error((options === null || options === void 0 ? void 0 : options.errMsg) || "".concat(msg, "\u53EA\u5305\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\u6216\u51CF\u53F7\uFF1B\u9996\u5B57\u6BCD\u5FC5\u987B\u4E3A\u5B57\u6BCD\uFF1B\u957F\u5EA6\u4E3A6-18\u4E2A\u5B57\u7B26\uFF1B\u4E0D\u80FD\u5305\u542B\u7279\u6B8A\u5B57\u7B26")))];
479
514
  }
480
515
  if (type === 'PASSWORD') {
481
- return [2 /*return*/, Promise.reject(new Error((options === null || options === void 0 ? void 0 : options.errMsg) || "".concat((options === null || options === void 0 ? void 0 : options.label) || common_1.STR_TYPE[type], "\u5FC5\u987B\u957F\u5EA6\u8D85\u8FC78-15\u4F4D\uFF0C\u5305\u62EC\u5927\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u7279\u6B8A\u7B26\u53F7")))];
516
+ return [2 /*return*/, Promise.reject(new Error((options === null || options === void 0 ? void 0 : options.errMsg) || "".concat(msg, "\u5FC5\u987B\u957F\u5EA6\u8D85\u8FC78-15\u4F4D\uFF0C\u5305\u62EC\u5927\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u7279\u6B8A\u7B26\u53F7")))];
482
517
  }
483
- return [2 /*return*/, Promise.reject(new Error((options === null || options === void 0 ? void 0 : options.errMsg) || "\u683C\u5F0F\u9519\u8BEF\uFF0C\u8BF7\u8F93\u5165\u6B63\u786E\u7684".concat((options === null || options === void 0 ? void 0 : options.label) || common_1.STR_TYPE[type], "\uFF01")))];
518
+ return [2 /*return*/, Promise.reject(new Error((options === null || options === void 0 ? void 0 : options.errMsg) || "\u683C\u5F0F\u9519\u8BEF\uFF0C\u8BF7\u8F93\u5165\u6B63\u786E\u7684".concat(msg, "\uFF01")))];
484
519
  });
485
520
  });
486
521
  }
487
- }];
522
+ }], false);
488
523
  }
489
524
  CheckUtil.getFormItemRules = getFormItemRules;
490
525
  })(CheckUtil || (CheckUtil = {}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tools-min-ns",
3
3
  "description": "工具包适用于前端以及node",
4
- "version": "1.8.1",
4
+ "version": "1.9.0",
5
5
  "main": "lib/index.js",
6
6
  "license": "MIT",
7
7
  "author": "nanshen",