@mi-avalon/libs 0.0.25 → 0.0.26
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/dist/constants/date.d.ts +2 -0
- package/dist/constants/date.js +2 -0
- package/dist/constants/pattern.d.ts +66 -0
- package/dist/constants/pattern.js +66 -22
- package/dist/index.es.js +1323 -1034
- package/dist/index.umd.js +16 -16
- package/dist/utils/calc.d.ts +179 -12
- package/dist/utils/calc.js +355 -81
- package/package.json +1 -1
package/dist/constants/date.d.ts
CHANGED
package/dist/constants/date.js
CHANGED
|
@@ -1,24 +1,90 @@
|
|
|
1
1
|
export declare class PatternType {
|
|
2
|
+
/**
|
|
3
|
+
* 整数
|
|
4
|
+
*/
|
|
2
5
|
static readonly integerRegex: RegExp;
|
|
6
|
+
/**
|
|
7
|
+
* 正整数
|
|
8
|
+
*/
|
|
3
9
|
static readonly positiveIntegerRegex: RegExp;
|
|
10
|
+
/**
|
|
11
|
+
* 负整数
|
|
12
|
+
*/
|
|
4
13
|
static readonly negativeIntegerRegex: RegExp;
|
|
14
|
+
/**
|
|
15
|
+
* 浮点数
|
|
16
|
+
*/
|
|
5
17
|
static readonly floatRegex: RegExp;
|
|
18
|
+
/**
|
|
19
|
+
* 字母
|
|
20
|
+
*/
|
|
6
21
|
static readonly letter: RegExp;
|
|
22
|
+
/**
|
|
23
|
+
* 汉字
|
|
24
|
+
*/
|
|
7
25
|
static readonly chinese: RegExp;
|
|
26
|
+
/**
|
|
27
|
+
* 数字
|
|
28
|
+
*/
|
|
8
29
|
static readonly number: RegExp;
|
|
30
|
+
/**
|
|
31
|
+
* 用户名 字母开头,允许字母数字下划线,长度4-16
|
|
32
|
+
*/
|
|
9
33
|
static readonly username: RegExp;
|
|
34
|
+
/**
|
|
35
|
+
* 强用户名 必须包含大小写字母和数字,6-20位
|
|
36
|
+
*/
|
|
10
37
|
static readonly strongUsername: RegExp;
|
|
38
|
+
/**
|
|
39
|
+
* 密码 至少8位,包含字母和数字
|
|
40
|
+
*/
|
|
11
41
|
static readonly password: RegExp;
|
|
42
|
+
/**
|
|
43
|
+
* 强密码 至少8位,包含大小写字母、数字和特殊字符
|
|
44
|
+
*/
|
|
12
45
|
static readonly strongPassword: RegExp;
|
|
46
|
+
/**
|
|
47
|
+
* 中国大陆的手机号
|
|
48
|
+
*/
|
|
13
49
|
static readonly phone: RegExp;
|
|
50
|
+
/**
|
|
51
|
+
* 带区号的手机号
|
|
52
|
+
*/
|
|
14
53
|
static readonly phoneWithAreaCode: RegExp;
|
|
54
|
+
/**
|
|
55
|
+
* 邮箱
|
|
56
|
+
*/
|
|
15
57
|
static readonly email: RegExp;
|
|
58
|
+
/**
|
|
59
|
+
* 身份证
|
|
60
|
+
*/
|
|
16
61
|
static readonly idCard: RegExp;
|
|
62
|
+
/**
|
|
63
|
+
* 银行卡
|
|
64
|
+
*/
|
|
17
65
|
static readonly bankCard: RegExp;
|
|
66
|
+
/**
|
|
67
|
+
* 邮政编码
|
|
68
|
+
*/
|
|
18
69
|
static readonly zipCode: RegExp;
|
|
70
|
+
/**
|
|
71
|
+
* IP
|
|
72
|
+
*/
|
|
19
73
|
static readonly ip: RegExp;
|
|
74
|
+
/**
|
|
75
|
+
* URL
|
|
76
|
+
*/
|
|
20
77
|
static readonly url: RegExp;
|
|
78
|
+
/**
|
|
79
|
+
* 车牌
|
|
80
|
+
*/
|
|
21
81
|
static readonly carNumber: RegExp;
|
|
82
|
+
/**
|
|
83
|
+
* 时间 hh:mm:ss
|
|
84
|
+
*/
|
|
22
85
|
static readonly time: RegExp;
|
|
86
|
+
/**
|
|
87
|
+
* 日期 YYYY-MM-DD
|
|
88
|
+
*/
|
|
23
89
|
static readonly date: RegExp;
|
|
24
90
|
}
|
|
@@ -1,46 +1,90 @@
|
|
|
1
1
|
export class PatternType {
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* 整数
|
|
4
|
+
*/
|
|
3
5
|
static integerRegex = /^-?\d+$/;
|
|
4
|
-
|
|
6
|
+
/**
|
|
7
|
+
* 正整数
|
|
8
|
+
*/
|
|
5
9
|
static positiveIntegerRegex = /^[1-9]\d*$/;
|
|
6
|
-
|
|
10
|
+
/**
|
|
11
|
+
* 负整数
|
|
12
|
+
*/
|
|
7
13
|
static negativeIntegerRegex = /^-[1-9]\d*$/;
|
|
8
|
-
|
|
14
|
+
/**
|
|
15
|
+
* 浮点数
|
|
16
|
+
*/
|
|
9
17
|
static floatRegex = /^-?\d+(\.\d+)?$/;
|
|
10
|
-
|
|
18
|
+
/**
|
|
19
|
+
* 字母
|
|
20
|
+
*/
|
|
11
21
|
static letter = /^[a-zA-Z]+$/;
|
|
12
|
-
|
|
22
|
+
/**
|
|
23
|
+
* 汉字
|
|
24
|
+
*/
|
|
13
25
|
static chinese = /^[\u4e00-\u9fa5]+$/;
|
|
14
|
-
|
|
26
|
+
/**
|
|
27
|
+
* 数字
|
|
28
|
+
*/
|
|
15
29
|
static number = /^[0-9]*$/;
|
|
16
|
-
|
|
30
|
+
/**
|
|
31
|
+
* 用户名 字母开头,允许字母数字下划线,长度4-16
|
|
32
|
+
*/
|
|
17
33
|
static username = /^[a-zA-Z]\w{3,15}$/;
|
|
18
|
-
|
|
34
|
+
/**
|
|
35
|
+
* 强用户名 必须包含大小写字母和数字,6-20位
|
|
36
|
+
*/
|
|
19
37
|
static strongUsername = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{6,20}$/;
|
|
20
|
-
|
|
38
|
+
/**
|
|
39
|
+
* 密码 至少8位,包含字母和数字
|
|
40
|
+
*/
|
|
21
41
|
static password = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/;
|
|
22
|
-
|
|
42
|
+
/**
|
|
43
|
+
* 强密码 至少8位,包含大小写字母、数字和特殊字符
|
|
44
|
+
*/
|
|
23
45
|
static strongPassword = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;
|
|
24
|
-
|
|
46
|
+
/**
|
|
47
|
+
* 中国大陆的手机号
|
|
48
|
+
*/
|
|
25
49
|
static phone = /^1[3-9]\d{9}$/;
|
|
26
|
-
|
|
50
|
+
/**
|
|
51
|
+
* 带区号的手机号
|
|
52
|
+
*/
|
|
27
53
|
static phoneWithAreaCode = /^\+?\d{2,3}-?\d{8,11}$/;
|
|
28
|
-
|
|
54
|
+
/**
|
|
55
|
+
* 邮箱
|
|
56
|
+
*/
|
|
29
57
|
static email = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
30
|
-
|
|
58
|
+
/**
|
|
59
|
+
* 身份证
|
|
60
|
+
*/
|
|
31
61
|
static idCard = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
|
|
32
|
-
|
|
62
|
+
/**
|
|
63
|
+
* 银行卡
|
|
64
|
+
*/
|
|
33
65
|
static bankCard = /^[1-9]\d{3,30}$/;
|
|
34
|
-
|
|
66
|
+
/**
|
|
67
|
+
* 邮政编码
|
|
68
|
+
*/
|
|
35
69
|
static zipCode = /^[1-9]\d{5}$/;
|
|
36
|
-
|
|
70
|
+
/**
|
|
71
|
+
* IP
|
|
72
|
+
*/
|
|
37
73
|
static ip = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
|
|
38
|
-
|
|
74
|
+
/**
|
|
75
|
+
* URL
|
|
76
|
+
*/
|
|
39
77
|
static url = /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/;
|
|
40
|
-
|
|
78
|
+
/**
|
|
79
|
+
* 车牌
|
|
80
|
+
*/
|
|
41
81
|
static carNumber = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]$/;
|
|
42
|
-
|
|
82
|
+
/**
|
|
83
|
+
* 时间 hh:mm:ss
|
|
84
|
+
*/
|
|
43
85
|
static time = /^([0-1][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/;
|
|
44
|
-
|
|
86
|
+
/**
|
|
87
|
+
* 日期 YYYY-MM-DD
|
|
88
|
+
*/
|
|
45
89
|
static date = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
46
90
|
}
|