phecda-core 2.0.0-alpha.7 → 2.0.1-alpha.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.
@@ -1,209 +0,0 @@
1
- "use strict";
2
- var Phecda = (() => {
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to2, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to2, key) && key !== except)
16
- __defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to2;
19
- };
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
-
22
- // src/preset/index.ts
23
- var preset_exports = {};
24
- __export(preset_exports, {
25
- isArray: () => isArray,
26
- isBoolean: () => isBoolean,
27
- isCnName: () => isCnName,
28
- isDate: () => isDate,
29
- isEnName: () => isEnName,
30
- isHexColor: () => isHexColor,
31
- isIdCard: () => isIdCard,
32
- isLandline: () => isLandline,
33
- isMailBox: () => isMailBox,
34
- isMobile: () => isMobile,
35
- isNumber: () => isNumber,
36
- isObject: () => isObject,
37
- isOption: () => isOption,
38
- isPostalCode: () => isPostalCode,
39
- isString: () => isString,
40
- isWechat: () => isWechat,
41
- toNumber: () => toNumber,
42
- toString: () => toString
43
- });
44
-
45
- // src/core.ts
46
- function init(target) {
47
- if (!target)
48
- return;
49
- if (!target.hasOwnProperty("_namespace")) {
50
- target._namespace = {
51
- __INIT_EVENT__: /* @__PURE__ */ new Set(),
52
- __EXPOSE_VAR__: /* @__PURE__ */ new Set(),
53
- __IGNORE_VAR__: /* @__PURE__ */ new Set(),
54
- __STATE_VAR__: /* @__PURE__ */ new Set(),
55
- __STATE_HANDLER__: /* @__PURE__ */ new Map(),
56
- __STATE_NAMESPACE__: /* @__PURE__ */ new Map()
57
- };
58
- }
59
- }
60
- __name(init, "init");
61
- function setModelVar(target, key) {
62
- init(target);
63
- target._namespace.__STATE_VAR__.add(key);
64
- setExposeKey(target, key);
65
- }
66
- __name(setModelVar, "setModelVar");
67
- function setExposeKey(target, key) {
68
- init(target);
69
- target._namespace.__EXPOSE_VAR__.add(key);
70
- }
71
- __name(setExposeKey, "setExposeKey");
72
- function regisHandler(target, key, handler) {
73
- init(target);
74
- if (!target._namespace.__STATE_HANDLER__.has(key))
75
- target._namespace.__STATE_HANDLER__.set(key, [
76
- handler
77
- ]);
78
- else
79
- target._namespace.__STATE_HANDLER__.get(key).push(handler);
80
- }
81
- __name(regisHandler, "regisHandler");
82
-
83
- // src/decorators.ts
84
- function Rule(rule, info, meta) {
85
- return (obj, key) => {
86
- setModelVar(obj, key);
87
- regisHandler(obj, key, {
88
- rule,
89
- info,
90
- meta
91
- });
92
- };
93
- }
94
- __name(Rule, "Rule");
95
- function Pipe(v) {
96
- return (obj, key) => {
97
- setModelVar(obj, key);
98
- regisHandler(obj, key, {
99
- async pipe(instance) {
100
- const tasks = v.value;
101
- for (const task of tasks)
102
- instance[key] = await task(instance[key]);
103
- }
104
- });
105
- };
106
- }
107
- __name(Pipe, "Pipe");
108
- function Empty(_target) {
109
- }
110
- __name(Empty, "Empty");
111
- var EmptyProxy = new Proxy(Empty, {
112
- apply() {
113
- return EmptyProxy;
114
- }
115
- });
116
-
117
- // src/preset/rule.ts
118
- function isOption() {
119
- return Rule((param) => param === void 0 ? "ok" : true, "");
120
- }
121
- __name(isOption, "isOption");
122
- function isArray(info) {
123
- return Rule((param) => Array.isArray(param), info || ((k) => `'${k}' should be an array`));
124
- }
125
- __name(isArray, "isArray");
126
- function isBoolean(info) {
127
- return Rule((param) => [
128
- true,
129
- false
130
- ].includes(param), info || ((k) => `'${k}' should be boolean`));
131
- }
132
- __name(isBoolean, "isBoolean");
133
- function isNumber(info) {
134
- return Rule((param) => typeof param === "number", info || ((k) => `'${k}' should be number`));
135
- }
136
- __name(isNumber, "isNumber");
137
- function isString(info) {
138
- return Rule((param) => typeof param === "string", info || ((k) => `'${k}' should be a string`));
139
- }
140
- __name(isString, "isString");
141
- function isObject(info) {
142
- return Rule((param) => {
143
- return Object.prototype.toString.call(param) === "[object Object]";
144
- }, info || ((k) => `'${k}' should be an object`));
145
- }
146
- __name(isObject, "isObject");
147
- function isMobile(info) {
148
- return Rule(/^((\+|00)86)?1((3[\d])|(4[5,6,7,9])|(5[0-3,5-9])|(6[5-7])|(7[0-8])|(8[\d])|(9[1,8,9]))\d{8}$/, info || ((k) => `'${k}' should be a mobile phone number`));
149
- }
150
- __name(isMobile, "isMobile");
151
- function isLandline(info) {
152
- return Rule(/\d{3}-\d{8}|\d{4}-\d{7}/, info || ((k) => `'${k}' should be a landline`));
153
- }
154
- __name(isLandline, "isLandline");
155
- function isMailBox(info) {
156
- return Rule(/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/, info || ((k) => `'${k}' should be a mailbox`));
157
- }
158
- __name(isMailBox, "isMailBox");
159
- function isIdCard(info) {
160
- return Rule(/(^\d{8}(0\d|10|11|12)([0-2]\d|30|31)\d{3}$)|(^\d{6}(18|19|20)\d{2}(0\d|10|11|12)([0-2]\d|30|31)\d{3}(\d|X|x)$)/, info || ((k) => `'${k}' should be an identity card number`));
161
- }
162
- __name(isIdCard, "isIdCard");
163
- function isCnName(info) {
164
- return Rule(/^([\u4E00-\u9FA5·]{2,16})$/, info || ((k) => `'${k}' \u9700\u8981\u662F\u4E00\u4E2A\u5408\u7406\u7684\u4E2D\u6587\u540D\u5B57`));
165
- }
166
- __name(isCnName, "isCnName");
167
- function isEnName(info) {
168
- return Rule(/(^[a-zA-Z]{1}[a-zA-Z\s]{0,20}[a-zA-Z]{1}$)/, info || ((k) => `'${k}' should be a valid en-name`));
169
- }
170
- __name(isEnName, "isEnName");
171
- function isDate(info) {
172
- return Rule(/^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/, info || ((k) => `'${k}' should be a valid date`));
173
- }
174
- __name(isDate, "isDate");
175
- function isWechat(info) {
176
- return Rule(/^[a-zA-Z]([-_a-zA-Z0-9]{5,19})+$/, info || ((k) => `'${k}' should be a valid wechat`));
177
- }
178
- __name(isWechat, "isWechat");
179
- function isHexColor(info) {
180
- return Rule(/^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/, info || ((k) => `'${k}' should be a valid hex-color`));
181
- }
182
- __name(isHexColor, "isHexColor");
183
- function isPostalCode(info) {
184
- return Rule(/^(0[1-7]|1[0-356]|2[0-7]|3[0-6]|4[0-7]|5[1-7]|6[1-7]|7[0-5]|8[013-6])\d{4}$/, info || ((k) => `'${k}' should be a valid postal code`));
185
- }
186
- __name(isPostalCode, "isPostalCode");
187
-
188
- // src/helper.ts
189
- function to(task, oldTasks) {
190
- const tasks = oldTasks || [];
191
- tasks.push(task);
192
- return {
193
- to: (task2) => to(task2, tasks),
194
- value: tasks
195
- };
196
- }
197
- __name(to, "to");
198
-
199
- // src/preset/pipe.ts
200
- function toNumber() {
201
- return Pipe(to((param) => Number(param)));
202
- }
203
- __name(toNumber, "toNumber");
204
- function toString() {
205
- return Pipe(to((param) => String(param)));
206
- }
207
- __name(toString, "toString");
208
- return __toCommonJS(preset_exports);
209
- })();
@@ -1,228 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to2, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to2, key) && key !== except)
15
- __defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to2;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
-
21
- // src/preset/index.ts
22
- var preset_exports = {};
23
- __export(preset_exports, {
24
- isArray: () => isArray,
25
- isBoolean: () => isBoolean,
26
- isCnName: () => isCnName,
27
- isDate: () => isDate,
28
- isEnName: () => isEnName,
29
- isHexColor: () => isHexColor,
30
- isIdCard: () => isIdCard,
31
- isLandline: () => isLandline,
32
- isMailBox: () => isMailBox,
33
- isMobile: () => isMobile,
34
- isNumber: () => isNumber,
35
- isObject: () => isObject,
36
- isOption: () => isOption,
37
- isPostalCode: () => isPostalCode,
38
- isString: () => isString,
39
- isWechat: () => isWechat,
40
- toNumber: () => toNumber,
41
- toString: () => toString
42
- });
43
- module.exports = __toCommonJS(preset_exports);
44
-
45
- // src/core.ts
46
- function init(target) {
47
- if (!target)
48
- return;
49
- if (!target.hasOwnProperty("_namespace")) {
50
- target._namespace = {
51
- __INIT_EVENT__: /* @__PURE__ */ new Set(),
52
- __EXPOSE_VAR__: /* @__PURE__ */ new Set(),
53
- __IGNORE_VAR__: /* @__PURE__ */ new Set(),
54
- __STATE_VAR__: /* @__PURE__ */ new Set(),
55
- __STATE_HANDLER__: /* @__PURE__ */ new Map(),
56
- __STATE_NAMESPACE__: /* @__PURE__ */ new Map()
57
- };
58
- }
59
- }
60
- __name(init, "init");
61
- function setModelVar(target, key) {
62
- init(target);
63
- target._namespace.__STATE_VAR__.add(key);
64
- setExposeKey(target, key);
65
- }
66
- __name(setModelVar, "setModelVar");
67
- function setExposeKey(target, key) {
68
- init(target);
69
- target._namespace.__EXPOSE_VAR__.add(key);
70
- }
71
- __name(setExposeKey, "setExposeKey");
72
- function regisHandler(target, key, handler) {
73
- init(target);
74
- if (!target._namespace.__STATE_HANDLER__.has(key))
75
- target._namespace.__STATE_HANDLER__.set(key, [
76
- handler
77
- ]);
78
- else
79
- target._namespace.__STATE_HANDLER__.get(key).push(handler);
80
- }
81
- __name(regisHandler, "regisHandler");
82
-
83
- // src/decorators.ts
84
- function Rule(rule, info, meta) {
85
- return (obj, key) => {
86
- setModelVar(obj, key);
87
- regisHandler(obj, key, {
88
- rule,
89
- info,
90
- meta
91
- });
92
- };
93
- }
94
- __name(Rule, "Rule");
95
- function Pipe(v) {
96
- return (obj, key) => {
97
- setModelVar(obj, key);
98
- regisHandler(obj, key, {
99
- async pipe(instance) {
100
- const tasks = v.value;
101
- for (const task of tasks)
102
- instance[key] = await task(instance[key]);
103
- }
104
- });
105
- };
106
- }
107
- __name(Pipe, "Pipe");
108
- function Empty(_target) {
109
- }
110
- __name(Empty, "Empty");
111
- var EmptyProxy = new Proxy(Empty, {
112
- apply() {
113
- return EmptyProxy;
114
- }
115
- });
116
-
117
- // src/preset/rule.ts
118
- function isOption() {
119
- return Rule((param) => param === void 0 ? "ok" : true, "");
120
- }
121
- __name(isOption, "isOption");
122
- function isArray(info) {
123
- return Rule((param) => Array.isArray(param), info || ((k) => `'${k}' should be an array`));
124
- }
125
- __name(isArray, "isArray");
126
- function isBoolean(info) {
127
- return Rule((param) => [
128
- true,
129
- false
130
- ].includes(param), info || ((k) => `'${k}' should be boolean`));
131
- }
132
- __name(isBoolean, "isBoolean");
133
- function isNumber(info) {
134
- return Rule((param) => typeof param === "number", info || ((k) => `'${k}' should be number`));
135
- }
136
- __name(isNumber, "isNumber");
137
- function isString(info) {
138
- return Rule((param) => typeof param === "string", info || ((k) => `'${k}' should be a string`));
139
- }
140
- __name(isString, "isString");
141
- function isObject(info) {
142
- return Rule((param) => {
143
- return Object.prototype.toString.call(param) === "[object Object]";
144
- }, info || ((k) => `'${k}' should be an object`));
145
- }
146
- __name(isObject, "isObject");
147
- function isMobile(info) {
148
- return Rule(/^((\+|00)86)?1((3[\d])|(4[5,6,7,9])|(5[0-3,5-9])|(6[5-7])|(7[0-8])|(8[\d])|(9[1,8,9]))\d{8}$/, info || ((k) => `'${k}' should be a mobile phone number`));
149
- }
150
- __name(isMobile, "isMobile");
151
- function isLandline(info) {
152
- return Rule(/\d{3}-\d{8}|\d{4}-\d{7}/, info || ((k) => `'${k}' should be a landline`));
153
- }
154
- __name(isLandline, "isLandline");
155
- function isMailBox(info) {
156
- return Rule(/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/, info || ((k) => `'${k}' should be a mailbox`));
157
- }
158
- __name(isMailBox, "isMailBox");
159
- function isIdCard(info) {
160
- return Rule(/(^\d{8}(0\d|10|11|12)([0-2]\d|30|31)\d{3}$)|(^\d{6}(18|19|20)\d{2}(0\d|10|11|12)([0-2]\d|30|31)\d{3}(\d|X|x)$)/, info || ((k) => `'${k}' should be an identity card number`));
161
- }
162
- __name(isIdCard, "isIdCard");
163
- function isCnName(info) {
164
- return Rule(/^([\u4E00-\u9FA5·]{2,16})$/, info || ((k) => `'${k}' \u9700\u8981\u662F\u4E00\u4E2A\u5408\u7406\u7684\u4E2D\u6587\u540D\u5B57`));
165
- }
166
- __name(isCnName, "isCnName");
167
- function isEnName(info) {
168
- return Rule(/(^[a-zA-Z]{1}[a-zA-Z\s]{0,20}[a-zA-Z]{1}$)/, info || ((k) => `'${k}' should be a valid en-name`));
169
- }
170
- __name(isEnName, "isEnName");
171
- function isDate(info) {
172
- return Rule(/^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/, info || ((k) => `'${k}' should be a valid date`));
173
- }
174
- __name(isDate, "isDate");
175
- function isWechat(info) {
176
- return Rule(/^[a-zA-Z]([-_a-zA-Z0-9]{5,19})+$/, info || ((k) => `'${k}' should be a valid wechat`));
177
- }
178
- __name(isWechat, "isWechat");
179
- function isHexColor(info) {
180
- return Rule(/^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/, info || ((k) => `'${k}' should be a valid hex-color`));
181
- }
182
- __name(isHexColor, "isHexColor");
183
- function isPostalCode(info) {
184
- return Rule(/^(0[1-7]|1[0-356]|2[0-7]|3[0-6]|4[0-7]|5[1-7]|6[1-7]|7[0-5]|8[013-6])\d{4}$/, info || ((k) => `'${k}' should be a valid postal code`));
185
- }
186
- __name(isPostalCode, "isPostalCode");
187
-
188
- // src/helper.ts
189
- function to(task, oldTasks) {
190
- const tasks = oldTasks || [];
191
- tasks.push(task);
192
- return {
193
- to: (task2) => to(task2, tasks),
194
- value: tasks
195
- };
196
- }
197
- __name(to, "to");
198
-
199
- // src/preset/pipe.ts
200
- function toNumber() {
201
- return Pipe(to((param) => Number(param)));
202
- }
203
- __name(toNumber, "toNumber");
204
- function toString() {
205
- return Pipe(to((param) => String(param)));
206
- }
207
- __name(toString, "toString");
208
- // Annotate the CommonJS export names for ESM import in node:
209
- 0 && (module.exports = {
210
- isArray,
211
- isBoolean,
212
- isCnName,
213
- isDate,
214
- isEnName,
215
- isHexColor,
216
- isIdCard,
217
- isLandline,
218
- isMailBox,
219
- isMobile,
220
- isNumber,
221
- isObject,
222
- isOption,
223
- isPostalCode,
224
- isString,
225
- isWechat,
226
- toNumber,
227
- toString
228
- });
@@ -1,186 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
- // src/core.ts
5
- function init(target) {
6
- if (!target)
7
- return;
8
- if (!target.hasOwnProperty("_namespace")) {
9
- target._namespace = {
10
- __INIT_EVENT__: /* @__PURE__ */ new Set(),
11
- __EXPOSE_VAR__: /* @__PURE__ */ new Set(),
12
- __IGNORE_VAR__: /* @__PURE__ */ new Set(),
13
- __STATE_VAR__: /* @__PURE__ */ new Set(),
14
- __STATE_HANDLER__: /* @__PURE__ */ new Map(),
15
- __STATE_NAMESPACE__: /* @__PURE__ */ new Map()
16
- };
17
- }
18
- }
19
- __name(init, "init");
20
- function setModelVar(target, key) {
21
- init(target);
22
- target._namespace.__STATE_VAR__.add(key);
23
- setExposeKey(target, key);
24
- }
25
- __name(setModelVar, "setModelVar");
26
- function setExposeKey(target, key) {
27
- init(target);
28
- target._namespace.__EXPOSE_VAR__.add(key);
29
- }
30
- __name(setExposeKey, "setExposeKey");
31
- function regisHandler(target, key, handler) {
32
- init(target);
33
- if (!target._namespace.__STATE_HANDLER__.has(key))
34
- target._namespace.__STATE_HANDLER__.set(key, [
35
- handler
36
- ]);
37
- else
38
- target._namespace.__STATE_HANDLER__.get(key).push(handler);
39
- }
40
- __name(regisHandler, "regisHandler");
41
-
42
- // src/decorators.ts
43
- function Rule(rule, info, meta) {
44
- return (obj, key) => {
45
- setModelVar(obj, key);
46
- regisHandler(obj, key, {
47
- rule,
48
- info,
49
- meta
50
- });
51
- };
52
- }
53
- __name(Rule, "Rule");
54
- function Pipe(v) {
55
- return (obj, key) => {
56
- setModelVar(obj, key);
57
- regisHandler(obj, key, {
58
- async pipe(instance) {
59
- const tasks = v.value;
60
- for (const task of tasks)
61
- instance[key] = await task(instance[key]);
62
- }
63
- });
64
- };
65
- }
66
- __name(Pipe, "Pipe");
67
- function Empty(_target) {
68
- }
69
- __name(Empty, "Empty");
70
- var EmptyProxy = new Proxy(Empty, {
71
- apply() {
72
- return EmptyProxy;
73
- }
74
- });
75
-
76
- // src/preset/rule.ts
77
- function isOption() {
78
- return Rule((param) => param === void 0 ? "ok" : true, "");
79
- }
80
- __name(isOption, "isOption");
81
- function isArray(info) {
82
- return Rule((param) => Array.isArray(param), info || ((k) => `'${k}' should be an array`));
83
- }
84
- __name(isArray, "isArray");
85
- function isBoolean(info) {
86
- return Rule((param) => [
87
- true,
88
- false
89
- ].includes(param), info || ((k) => `'${k}' should be boolean`));
90
- }
91
- __name(isBoolean, "isBoolean");
92
- function isNumber(info) {
93
- return Rule((param) => typeof param === "number", info || ((k) => `'${k}' should be number`));
94
- }
95
- __name(isNumber, "isNumber");
96
- function isString(info) {
97
- return Rule((param) => typeof param === "string", info || ((k) => `'${k}' should be a string`));
98
- }
99
- __name(isString, "isString");
100
- function isObject(info) {
101
- return Rule((param) => {
102
- return Object.prototype.toString.call(param) === "[object Object]";
103
- }, info || ((k) => `'${k}' should be an object`));
104
- }
105
- __name(isObject, "isObject");
106
- function isMobile(info) {
107
- return Rule(/^((\+|00)86)?1((3[\d])|(4[5,6,7,9])|(5[0-3,5-9])|(6[5-7])|(7[0-8])|(8[\d])|(9[1,8,9]))\d{8}$/, info || ((k) => `'${k}' should be a mobile phone number`));
108
- }
109
- __name(isMobile, "isMobile");
110
- function isLandline(info) {
111
- return Rule(/\d{3}-\d{8}|\d{4}-\d{7}/, info || ((k) => `'${k}' should be a landline`));
112
- }
113
- __name(isLandline, "isLandline");
114
- function isMailBox(info) {
115
- return Rule(/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/, info || ((k) => `'${k}' should be a mailbox`));
116
- }
117
- __name(isMailBox, "isMailBox");
118
- function isIdCard(info) {
119
- return Rule(/(^\d{8}(0\d|10|11|12)([0-2]\d|30|31)\d{3}$)|(^\d{6}(18|19|20)\d{2}(0\d|10|11|12)([0-2]\d|30|31)\d{3}(\d|X|x)$)/, info || ((k) => `'${k}' should be an identity card number`));
120
- }
121
- __name(isIdCard, "isIdCard");
122
- function isCnName(info) {
123
- return Rule(/^([\u4E00-\u9FA5·]{2,16})$/, info || ((k) => `'${k}' \u9700\u8981\u662F\u4E00\u4E2A\u5408\u7406\u7684\u4E2D\u6587\u540D\u5B57`));
124
- }
125
- __name(isCnName, "isCnName");
126
- function isEnName(info) {
127
- return Rule(/(^[a-zA-Z]{1}[a-zA-Z\s]{0,20}[a-zA-Z]{1}$)/, info || ((k) => `'${k}' should be a valid en-name`));
128
- }
129
- __name(isEnName, "isEnName");
130
- function isDate(info) {
131
- return Rule(/^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/, info || ((k) => `'${k}' should be a valid date`));
132
- }
133
- __name(isDate, "isDate");
134
- function isWechat(info) {
135
- return Rule(/^[a-zA-Z]([-_a-zA-Z0-9]{5,19})+$/, info || ((k) => `'${k}' should be a valid wechat`));
136
- }
137
- __name(isWechat, "isWechat");
138
- function isHexColor(info) {
139
- return Rule(/^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/, info || ((k) => `'${k}' should be a valid hex-color`));
140
- }
141
- __name(isHexColor, "isHexColor");
142
- function isPostalCode(info) {
143
- return Rule(/^(0[1-7]|1[0-356]|2[0-7]|3[0-6]|4[0-7]|5[1-7]|6[1-7]|7[0-5]|8[013-6])\d{4}$/, info || ((k) => `'${k}' should be a valid postal code`));
144
- }
145
- __name(isPostalCode, "isPostalCode");
146
-
147
- // src/helper.ts
148
- function to(task, oldTasks) {
149
- const tasks = oldTasks || [];
150
- tasks.push(task);
151
- return {
152
- to: (task2) => to(task2, tasks),
153
- value: tasks
154
- };
155
- }
156
- __name(to, "to");
157
-
158
- // src/preset/pipe.ts
159
- function toNumber() {
160
- return Pipe(to((param) => Number(param)));
161
- }
162
- __name(toNumber, "toNumber");
163
- function toString() {
164
- return Pipe(to((param) => String(param)));
165
- }
166
- __name(toString, "toString");
167
- export {
168
- isArray,
169
- isBoolean,
170
- isCnName,
171
- isDate,
172
- isEnName,
173
- isHexColor,
174
- isIdCard,
175
- isLandline,
176
- isMailBox,
177
- isMobile,
178
- isNumber,
179
- isObject,
180
- isOption,
181
- isPostalCode,
182
- isString,
183
- isWechat,
184
- toNumber,
185
- toString
186
- };