y-admin-ui 6.2.6 → 6.2.9

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/lib/style.css.gz CHANGED
Binary file
@@ -0,0 +1,364 @@
1
+ /**
2
+ * 验证百分比(不可以小数)
3
+ * @param val 当前值字符串
4
+ * @returns 返回处理后的字符串
5
+ */
6
+ export function verifyNumberPercentage(val: string): string {
7
+ // 匹配空格
8
+ let v = val.replace(/(^\s*)|(\s*$)/g, '');
9
+ // 只能是数字和小数点,不能是其他输入
10
+ v = v.replace(/[^\d]/g, '');
11
+ // 不能以0开始
12
+ v = v.replace(/^0/g, '');
13
+ // 数字超过100,赋值成最大值100
14
+ v = v.replace(/^[1-9]\d\d{1,3}$/, '100');
15
+ // 返回结果
16
+ return v;
17
+ }
18
+
19
+ /**
20
+ * 验证百分比(可以小数)
21
+ * @param val 当前值字符串
22
+ * @returns 返回处理后的字符串
23
+ */
24
+ export function verifyNumberPercentageFloat(val: string): string {
25
+ let v = verifyNumberIntegerAndFloat(val);
26
+ // 数字超过100,赋值成最大值100
27
+ v = v.replace(/^[1-9]\d\d{1,3}$/, '100');
28
+ // 超过100之后不给再输入值
29
+ v = v.replace(/^100\.$/, '100');
30
+ // 返回结果
31
+ return v;
32
+ }
33
+
34
+ /**
35
+ * 小数或整数(不可以负数)
36
+ * @param val 当前值字符串
37
+ * @returns 返回处理后的字符串
38
+ */
39
+ export function verifyNumberIntegerAndFloat(val: string) {
40
+ // 匹配空格
41
+ let v = val.replace(/(^\s*)|(\s*$)/g, '');
42
+ // 只能是数字和小数点,不能是其他输入
43
+ v = v.replace(/[^\d.]/g, '');
44
+ // 以0开始只能输入一个
45
+ v = v.replace(/^0{2}$/g, '0');
46
+ // 保证第一位只能是数字,不能是点
47
+ v = v.replace(/^\./g, '');
48
+ // 小数只能出现1位
49
+ v = v.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.');
50
+ // 小数点后面保留2位
51
+ v = v.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3');
52
+ // 返回结果
53
+ return v;
54
+ }
55
+
56
+ /**
57
+ * 正整数验证
58
+ * @param val 当前值字符串
59
+ * @returns 返回处理后的字符串
60
+ */
61
+ export function verifiyNumberInteger(val: string) {
62
+ // 匹配空格
63
+ let v = val.replace(/(^\s*)|(\s*$)/g, '');
64
+ // 去掉 '.' , 防止贴贴的时候出现问题 如 0.1.12.12
65
+ v = v.replace(/[\.]*/g, '');
66
+ // 去掉以 0 开始后面的数, 防止贴贴的时候出现问题 如 00121323
67
+ v = v.replace(/(^0[\d]*)$/g, '0');
68
+ // 首位是0,只能出现一次
69
+ v = v.replace(/^0\d$/g, '0');
70
+ // 只匹配数字
71
+ v = v.replace(/[^\d]/g, '');
72
+ // 返回结果
73
+ return v;
74
+ }
75
+
76
+ /**
77
+ * 去掉中文及空格
78
+ * @param val 当前值字符串
79
+ * @returns 返回处理后的字符串
80
+ */
81
+ export function verifyCnAndSpace(val: string) {
82
+ // 匹配中文与空格
83
+ let v = val.replace(/[\u4e00-\u9fa5\s]+/g, '');
84
+ // 匹配空格
85
+ v = v.replace(/(^\s*)|(\s*$)/g, '');
86
+ // 返回结果
87
+ return v;
88
+ }
89
+
90
+ /**
91
+ * 去掉英文及空格
92
+ * @param val 当前值字符串
93
+ * @returns 返回处理后的字符串
94
+ */
95
+ export function verifyEnAndSpace(val: string) {
96
+ // 匹配英文与空格
97
+ let v = val.replace(/[a-zA-Z]+/g, '');
98
+ // 匹配空格
99
+ v = v.replace(/(^\s*)|(\s*$)/g, '');
100
+ // 返回结果
101
+ return v;
102
+ }
103
+
104
+ /**
105
+ * 禁止输入空格
106
+ * @param val 当前值字符串
107
+ * @returns 返回处理后的字符串
108
+ */
109
+ export function verifyAndSpace(val: string) {
110
+ // 匹配空格
111
+ let v = val.replace(/(^\s*)|(\s*$)/g, '');
112
+ // 返回结果
113
+ return v;
114
+ }
115
+
116
+ /**
117
+ * 金额用 `,` 区分开
118
+ * @param val 当前值字符串
119
+ * @returns 返回处理后的字符串
120
+ */
121
+ export function verifyNumberComma(val: string) {
122
+ // 调用小数或整数(不可以负数)方法
123
+ let v: any = verifyNumberIntegerAndFloat(val);
124
+ // 字符串转成数组
125
+ v = v.toString().split('.');
126
+ // \B 匹配非单词边界,两边都是单词字符或者两边都是非单词字符
127
+ v[0] = v[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
128
+ // 数组转字符串
129
+ v = v.join('.');
130
+ // 返回结果
131
+ return v;
132
+ }
133
+
134
+ /**
135
+ * 匹配文字变色(搜索时)
136
+ * @param val 当前值字符串
137
+ * @param text 要处理的字符串值
138
+ * @param color 搜索到时字体高亮颜色
139
+ * @returns 返回处理后的字符串
140
+ */
141
+ export function verifyTextColor(val: string, text = '', color = 'red') {
142
+ // 返回内容,添加颜色
143
+ let v = text.replace(new RegExp(val, 'gi'), `<span style='color: ${color}'>${val}</span>`);
144
+ // 返回结果
145
+ return v;
146
+ }
147
+
148
+ /**
149
+ * 数字转中文大写
150
+ * @param val 当前值字符串
151
+ * @param unit 默认:仟佰拾亿仟佰拾万仟佰拾元角分
152
+ * @returns 返回处理后的字符串
153
+ */
154
+ export function verifyNumberCnUppercase(val: any, unit = '仟佰拾亿仟佰拾万仟佰拾元角分', v = '') {
155
+ // 当前内容字符串添加 2个0,为什么??
156
+ val += '00';
157
+ // 返回某个指定的字符串值在字符串中首次出现的位置,没有出现,则该方法返回 -1
158
+ let lookup = val.indexOf('.');
159
+ // substring:不包含结束下标内容,substr:包含结束下标内容
160
+ if (lookup >= 0) val = val.substring(0, lookup) + val.substr(lookup + 1, 2);
161
+ // 根据内容 val 的长度,截取返回对应大写
162
+ unit = unit.substr(unit.length - val.length);
163
+ // 循环截取拼接大写
164
+ for (let i = 0; i < val.length; i++) {
165
+ v += '零壹贰叁肆伍陆柒捌玖'.substr(val.substr(i, 1), 1) + unit.substr(i, 1);
166
+ }
167
+ // 正则处理
168
+ v = v
169
+ .replace(/零角零分$/, '整')
170
+ .replace(/零[仟佰拾]/g, '零')
171
+ .replace(/零{2,}/g, '零')
172
+ .replace(/零([亿|万])/g, '$1')
173
+ .replace(/零+元/, '元')
174
+ .replace(/亿零{0,3}万/, '亿')
175
+ .replace(/^元/, '零元');
176
+ // 返回结果
177
+ return v;
178
+ }
179
+
180
+ /**
181
+ * 手机号码
182
+ * @param val 当前值字符串
183
+ * @returns 返回 true: 手机号码正确
184
+ */
185
+ export function verifyPhone(val: string) {
186
+ // false: 手机号码不正确
187
+ if (!/^((12[0-9])|(13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0|1,5-9]))\d{8}$/.test(val)) return false;
188
+ // true: 手机号码正确
189
+ else return true;
190
+ }
191
+
192
+ /**
193
+ * 国内电话号码
194
+ * @param val 当前值字符串
195
+ * @returns 返回 true: 国内电话号码正确
196
+ */
197
+ export function verifyTelPhone(val: string) {
198
+ // false: 国内电话号码不正确
199
+ if (!/\d{3}-\d{8}|\d{4}-\d{7}/.test(val)) return false;
200
+ // true: 国内电话号码正确
201
+ else return true;
202
+ }
203
+
204
+ /**
205
+ * 登录账号 (字母开头,允许5-16字节,允许字母数字下划线)
206
+ * @param val 当前值字符串
207
+ * @returns 返回 true: 登录账号正确
208
+ */
209
+ export function verifyAccount(val: string) {
210
+ // false: 登录账号不正确
211
+ if (!/^[a-zA-Z][a-zA-Z0-9_]{4,15}$/.test(val)) return false;
212
+ // true: 登录账号正确
213
+ else return true;
214
+ }
215
+
216
+ /**
217
+ * 密码 (以字母开头,长度在6~16之间,只能包含字母、数字和下划线)
218
+ * @param val 当前值字符串
219
+ * @returns 返回 true: 密码正确
220
+ */
221
+ export function verifyPassword(val: string) {
222
+ // false: 密码不正确
223
+ if (!/^[a-zA-Z]\w{5,15}$/.test(val)) return false;
224
+ // true: 密码正确
225
+ else return true;
226
+ }
227
+
228
+ /**
229
+ * 强密码 (字母+数字+特殊字符,长度在6-16之间)
230
+ * @param val 当前值字符串
231
+ * @returns 返回 true: 强密码正确
232
+ */
233
+ export function verifyPasswordPowerful(val: string) {
234
+ // false: 强密码不正确
235
+ if (!/^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&\.*]+$)(?![a-zA-z\d]+$)(?![a-zA-z!@#$%^&\.*]+$)(?![\d!@#$%^&\.*]+$)[a-zA-Z\d!@#$%^&\.*]{6,16}$/.test(val))
236
+ return false;
237
+ // true: 强密码正确
238
+ else return true;
239
+ }
240
+
241
+ /**
242
+ * 密码强度
243
+ * @param val 当前值字符串
244
+ * @description 弱:纯数字,纯字母,纯特殊字符
245
+ * @description 中:字母+数字,字母+特殊字符,数字+特殊字符
246
+ * @description 强:字母+数字+特殊字符
247
+ * @returns 返回处理后的字符串:弱、中、强
248
+ */
249
+ export function verifyPasswordStrength(val: string) {
250
+ let v = '';
251
+ // 弱:纯数字,纯字母,纯特殊字符
252
+ if (/^(?:\d+|[a-zA-Z]+|[!@#$%^&\.*]+){6,16}$/.test(val)) v = '弱';
253
+ // 中:字母+数字,字母+特殊字符,数字+特殊字符
254
+ if (/^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&\.*]+$)[a-zA-Z\d!@#$%^&\.*]{6,16}$/.test(val)) v = '中';
255
+ // 强:字母+数字+特殊字符
256
+ if (/^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&\.*]+$)(?![a-zA-z\d]+$)(?![a-zA-z!@#$%^&\.*]+$)(?![\d!@#$%^&\.*]+$)[a-zA-Z\d!@#$%^&\.*]{6,16}$/.test(val))
257
+ v = '强';
258
+ // 返回结果
259
+ return v;
260
+ }
261
+
262
+ /**
263
+ * IP地址
264
+ * @param val 当前值字符串
265
+ * @returns 返回 true: IP地址正确
266
+ */
267
+ export function verifyIPAddress(val: string) {
268
+ // false: IP地址不正确
269
+ if (
270
+ !/^(\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])$/.test(
271
+ val
272
+ )
273
+ )
274
+ return false;
275
+ // true: IP地址正确
276
+ else return true;
277
+ }
278
+
279
+ /**
280
+ * 邮箱
281
+ * @param val 当前值字符串
282
+ * @returns 返回 true: 邮箱正确
283
+ */
284
+ export function verifyEmail(val: string) {
285
+ // false: 邮箱不正确
286
+ if (
287
+ !/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(
288
+ val
289
+ )
290
+ )
291
+ return false;
292
+ // true: 邮箱正确
293
+ else return true;
294
+ }
295
+
296
+ /**
297
+ * 身份证
298
+ * @param val 当前值字符串
299
+ * @returns 返回 true: 身份证正确
300
+ */
301
+ export function verifyIdCard(val: string) {
302
+ // false: 身份证不正确
303
+ if (!/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/.test(val)) return false;
304
+ // true: 身份证正确
305
+ else return true;
306
+ }
307
+
308
+ /**
309
+ * 姓名
310
+ * @param val 当前值字符串
311
+ * @returns 返回 true: 姓名正确
312
+ */
313
+ export function verifyFullName(val: string) {
314
+ // false: 姓名不正确
315
+ if (!/^[\u4e00-\u9fa5]{1,6}(·[\u4e00-\u9fa5]{1,6}){0,2}$/.test(val)) return false;
316
+ // true: 姓名正确
317
+ else return true;
318
+ }
319
+
320
+ /**
321
+ * 邮政编码
322
+ * @param val 当前值字符串
323
+ * @returns 返回 true: 邮政编码正确
324
+ */
325
+ export function verifyPostalCode(val: string) {
326
+ // false: 邮政编码不正确
327
+ if (!/^[1-9][0-9]{5}$/.test(val)) return false;
328
+ // true: 邮政编码正确
329
+ else return true;
330
+ }
331
+
332
+ /**
333
+ * url 处理
334
+ * @param val 当前值字符串
335
+ * @returns 返回 true: url 正确
336
+ */
337
+ export function verifyUrl(val: string) {
338
+ // false: url不正确
339
+ if (
340
+ !/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(
341
+ val
342
+ )
343
+ )
344
+ return false;
345
+ // true: url正确
346
+ else return true;
347
+ }
348
+
349
+ /**
350
+ * 车牌号
351
+ * @param val 当前值字符串
352
+ * @returns 返回 true:车牌号正确
353
+ */
354
+ export function verifyCarNum(val: string) {
355
+ // false: 车牌号不正确
356
+ if (
357
+ !/^(([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z](([0-9]{5}[DF])|([DF]([A-HJ-NP-Z0-9])[0-9]{4})))|([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳使领]))$/.test(
358
+ val
359
+ )
360
+ )
361
+ return false;
362
+ // true:车牌号正确
363
+ else return true;
364
+ }
@@ -0,0 +1,326 @@
1
+ // 手机号正则表达式
2
+ export const phoneReg = /^1\d{10}$/;
3
+
4
+ // 手机号正则表达式(强校验)
5
+ export const phoneStrongReg = /^(13[0-9]{9})|(15[0-9]{9})|(17[0-9]{9})|(18[0-9]{9})|(19[0-9]{9})$/;
6
+
7
+ // 固话正则表达式
8
+ export const telReg = /^(400|800)([0-9\\-]{7,10})|(([0-9]{4}|[0-9]{3})(-| )?)?([0-9]{7,8})((-| |转)*([0-9]{1,4}))?$/;
9
+
10
+ // 邮箱正则表达式
11
+ export const emailReg = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
12
+
13
+ // 网址正则表达式
14
+ export const urlReg = /(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/;
15
+
16
+ // 身份证正则表达式
17
+ export const identityReg = /(^\d{15}$)|(^\d{17}(x|X|\d)$)/;
18
+
19
+ // 日期正则表达式
20
+ export const dateReg = /^(\d{4})[-/](\d{1}|0\d{1}|1[0-2])([-/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/;
21
+
22
+ // 数字正则表达式
23
+ export const numberReg = /^[0-9]+\.?[0-9]*$/;
24
+
25
+ // 整数正则表达式
26
+ export const integerReg = /^-?\d+$/;
27
+
28
+ // 正整数正则表达式
29
+ export const positiveIntegerReg = /^[1-9]\d*$/;
30
+
31
+ // 负整数正则表达式
32
+ export const negativeIntegerReg = /^-[1-9]\d*$/;
33
+
34
+ // 非负整数(正整数或0)正则表达式
35
+ export const nonNegativeIntegerReg = /^\d+$/;
36
+
37
+ // 非正整数(负整数或0)正则表达式
38
+ export const nonPositiveIntegerReg = /^-[1-9]\d*|0/;
39
+
40
+ // 中文正则表达式
41
+ export const chineseReg = /^[\u4E00-\u9FA5]{2,4}$/;
42
+
43
+ // 端口号正则表达式
44
+ export const portReg = /^([0-9]|[1-9]\d|[1-9]\d{2}|[1-9]\d{3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$/;
45
+
46
+ // IP正则表达式
47
+ export const ipReg =
48
+ /^(\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])$/;
49
+
50
+ // 经度正则表达式, -180.0~+180.0(整数部分为0~180, 必须输入1到5位小数)
51
+ export const longitudeReg = /^[-|+]?(0?\d{1,2}\.\d{1,5}|1[0-7]?\d{1}\.\d{1,5}|180\.0{1,5})$/;
52
+
53
+ // 纬度正则表达式, -90.0~+90.0(整数部分为0~90, 必须输入1到5位小数)
54
+ export const latitudeReg = /^[-|+]?([0-8]?\d{1}\.\d{1,5}|90\.0{1,5})$/;
55
+
56
+ /**
57
+ * 是否是手机号
58
+ * @param value
59
+ * @returns {boolean}
60
+ */
61
+ export function isPhone(value) {
62
+ return phoneReg.test(value);
63
+ }
64
+
65
+ /**
66
+ * 是否是手机号(强校验)
67
+ * @param value
68
+ * @returns {boolean}
69
+ */
70
+ export function isPhoneStrong(value) {
71
+ return phoneStrongReg.test(value);
72
+ }
73
+
74
+ /**
75
+ * 是否为固话
76
+ * @param value
77
+ * @returns {boolean}
78
+ */
79
+ export function isTel(value) {
80
+ return telReg.test(value);
81
+ }
82
+
83
+ /**
84
+ * 是否是邮箱
85
+ * @param value
86
+ * @returns {boolean}
87
+ */
88
+ export function isEmail(value) {
89
+ return emailReg.test(value);
90
+ }
91
+
92
+ /**
93
+ * 是否是网址
94
+ * @param value
95
+ * @returns {boolean}
96
+ */
97
+ export function isUrl(value) {
98
+ return urlReg.test(value);
99
+ }
100
+
101
+ /**
102
+ * 是否是身份证
103
+ * @param value
104
+ * @returns {boolean}
105
+ */
106
+ export function isIdentity(value) {
107
+ return identityReg.test(value);
108
+ }
109
+
110
+ /**
111
+ * 是否是日期
112
+ * @param value
113
+ * @returns {boolean}
114
+ */
115
+ export function isDate(value) {
116
+ return dateReg.test(value);
117
+ }
118
+
119
+ /**
120
+ * 是否是数字
121
+ * @param value
122
+ * @returns {boolean}
123
+ */
124
+ export function isNumber(value) {
125
+ //return !isNaN(value);
126
+ return numberReg.test(value);
127
+ }
128
+
129
+ /**
130
+ * 是否是整数
131
+ * @param value
132
+ * @returns {boolean}
133
+ */
134
+ export function isInteger(value) {
135
+ return integerReg.test(value);
136
+ }
137
+
138
+ /**
139
+ * 是否是正整数
140
+ * @param value
141
+ * @returns {boolean}
142
+ */
143
+ export function isPositiveInteger(value) {
144
+ return positiveIntegerReg.test(value);
145
+ }
146
+
147
+ /**
148
+ * 是否是负整数
149
+ * @param value
150
+ * @returns {boolean}
151
+ */
152
+ export function isNegativeInteger(value) {
153
+ return negativeIntegerReg.test(value);
154
+ }
155
+
156
+ /**
157
+ * 是否是非负整数(正整数或0)
158
+ * @param value
159
+ * @returns {boolean}
160
+ */
161
+ export function isNonNegativeInteger(value) {
162
+ return nonNegativeIntegerReg.test(value);
163
+ }
164
+
165
+ /**
166
+ * 是否是非正整数(负整数或0)
167
+ * @param value
168
+ * @returns {boolean}
169
+ */
170
+ export function isNonPositiveInteger(value) {
171
+ return nonPositiveIntegerReg.test(value);
172
+ }
173
+
174
+ /**
175
+ * 是否是中文
176
+ * @param value
177
+ * @returns {boolean}
178
+ */
179
+ export function isChinese(value) {
180
+ return chineseReg.test(value);
181
+ }
182
+
183
+ /**
184
+ * 是否是端口号
185
+ * @param value
186
+ * @returns {boolean}
187
+ */
188
+ export function isPort(value) {
189
+ return portReg.test(value);
190
+ }
191
+
192
+ /**
193
+ * 是否是IP
194
+ * @param value
195
+ * @returns {boolean}
196
+ */
197
+ export function isIP(value) {
198
+ return ipReg.test(value);
199
+ }
200
+
201
+ /**
202
+ * 是否是经度, -180.0~+180.0(整数部分为0~180, 必须输入1到5位小数)
203
+ * @param value
204
+ * @returns {boolean}
205
+ */
206
+ export function isLongitude(value) {
207
+ return longitudeReg.test(value);
208
+ }
209
+
210
+ /**
211
+ * 是否是纬度, -90.0~+90.0(整数部分为0~90, 必须输入1到5位小数)
212
+ * @param value
213
+ * @returns {boolean}
214
+ */
215
+ export function isLatitude(value) {
216
+ return latitudeReg.test(value);
217
+ }
218
+
219
+ /**
220
+ * 验证最小长度、最大长度
221
+ * @param value
222
+ * @param minLength
223
+ * @param maxLength
224
+ * @returns {boolean}
225
+ */
226
+ export function maxMinLength(value, minLength, maxLength) {
227
+ if (typeof value === 'undefined' || value === null) {
228
+ return !minLength;
229
+ }
230
+ if (minLength && value.toString().length < minLength) {
231
+ return false;
232
+ }
233
+ return !(typeof maxLength !== 'undefined' && maxLength !== null && value.toString().length > maxLength);
234
+ }
235
+
236
+ /**
237
+ * 验证最小值、最大值
238
+ * @param value
239
+ * @param min
240
+ * @param max
241
+ * @returns {boolean}
242
+ */
243
+ export function maxMin(value, min, max) {
244
+ if (typeof value === 'undefined' || value === null) {
245
+ return typeof min === 'undefined' || min === null;
246
+ }
247
+ if (typeof min !== 'undefined' && min !== null && value < min) {
248
+ return false;
249
+ }
250
+ return !(typeof max !== 'undefined' && max !== null && value > max);
251
+ }
252
+
253
+ /**
254
+ * 是否是身份证(强校验)
255
+ * @param value
256
+ * @returns {string}
257
+ */
258
+ export function isIdentityStrong(value) {
259
+ if (!isIdentity(value)) {
260
+ return '身份证号码格式错误';
261
+ }
262
+ const ai = value.length === 18 ? value.substring(0, 17) : value.substring(0, 6) + '19' + value.substring(6, 15);
263
+ // 验证出生年月
264
+ const year = ai.substring(6, 10); // 年
265
+ const birthday = year + '/' + ai.substring(10, 12) + '/' + ai.substring(12, 14);
266
+ if (!isDate(birthday)) {
267
+ return '身份证号码出生日期无效';
268
+ }
269
+ const now = new Date();
270
+ if (now.getFullYear() - parseInt(year) > 150 || now.getTime() - new Date(birthday).getTime() < 0) {
271
+ return '身份证号码出生日期不在有效范围';
272
+ }
273
+ // 验证地区码
274
+ const areaCodes = [
275
+ '11',
276
+ '12',
277
+ '13',
278
+ '14',
279
+ '15',
280
+ '21',
281
+ '22',
282
+ '23',
283
+ '31',
284
+ '32',
285
+ '33',
286
+ '34',
287
+ '35',
288
+ '36',
289
+ '37',
290
+ '41',
291
+ '42',
292
+ '43',
293
+ '44',
294
+ '45',
295
+ '46',
296
+ '50',
297
+ '51',
298
+ '52',
299
+ '53',
300
+ '54',
301
+ '61',
302
+ '62',
303
+ '63',
304
+ '64',
305
+ '65',
306
+ '71',
307
+ '81',
308
+ '82',
309
+ '91',
310
+ ];
311
+ if (areaCodes.indexOf(ai.substring(0, 2)) === -1) {
312
+ return '身份证号码地区编码错误';
313
+ }
314
+ // 验证最后一位
315
+ if (value.length === 18) {
316
+ const valCode = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
317
+ const wi = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
318
+ let totalMulAiWi = 0;
319
+ for (let i = 0; i < 17; i++) {
320
+ totalMulAiWi += parseInt(ai.charAt(i)) * wi[i];
321
+ }
322
+ if (value !== ai + valCode[totalMulAiWi % 11]) {
323
+ return '身份证号码最后一位错误';
324
+ }
325
+ }
326
+ }