@jhqn/utils-core 0.0.1-beta.12 → 0.0.1-beta.13

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/index.cjs CHANGED
@@ -85,6 +85,20 @@ const isTel = (val) => {
85
85
  return false;
86
86
  return cnTelRE.test(val.toString());
87
87
  };
88
+ const isEmail = (val) => {
89
+ if (!isDef(val))
90
+ return false;
91
+ const reg = /^[a-zA-Z\d](?:\w|-)+@[a-zA-Z\d]+\.[a-zA-Z]{2,5}$/;
92
+ return reg.test(val);
93
+ };
94
+ const isIdCard = (val) => {
95
+ if (!isDef(val))
96
+ return false;
97
+ const card15 = /^[1-9]\d{7}(?:0[1-9]|10|11|12)(?:[0-2][1-9]|10|20|30|31)\d{2}[\dXx]$/;
98
+ const card18 = /^[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}[\dXx]$/;
99
+ return card15.test(val) || card18.test(val);
100
+ };
101
+ const nonASCII = (text) => /[^\x20-\x7E]/.test(text);
88
102
  const isValidRes = (res) => res.code === 200 && res.data;
89
103
  const isValidArrRes = (res) => res.code === 200 && Array.isArray(res.data);
90
104
  const isValidPageRes = (res) => res.code === 200 && res.data && Array.isArray(res.data.list || res.data.records);
@@ -232,6 +246,8 @@ exports.hidePhone = hidePhone;
232
246
  exports.hideThird = hideThird;
233
247
  exports.isArrStr = isArrStr;
234
248
  exports.isDef = isDef;
249
+ exports.isEmail = isEmail;
250
+ exports.isIdCard = isIdCard;
235
251
  exports.isJSONStr = isJSONStr;
236
252
  exports.isNumeric = isNumeric;
237
253
  exports.isPhone = isPhone;
@@ -255,6 +271,7 @@ exports.kebab2Camel = kebab2Camel;
255
271
  exports.kebab2Pascal = kebab2Pascal;
256
272
  exports.kebab2Snake = kebab2Snake;
257
273
  exports.kebab2Title = kebab2Title;
274
+ exports.nonASCII = nonASCII;
258
275
  exports.parseToJSON = parseToJSON;
259
276
  exports.pascal2Camel = pascal2Camel;
260
277
  exports.pascal2Kebab = pascal2Kebab;
package/dist/index.d.ts CHANGED
@@ -218,6 +218,10 @@ declare type NullOrUndefinable<T> = Nullable<Undefinable<T>>;
218
218
  * 请求结果
219
219
  */
220
220
  declare type Res<T = any> = Service.Response<T>;
221
+ /**
222
+ * 分页请求结果数据
223
+ */
224
+ declare type PageResData<T = any> = Service.PageResponseData<T>;
221
225
  /**
222
226
  * 分页请求结果
223
227
  */
@@ -502,6 +506,21 @@ declare const isPhone: (val: NullOrUndefinable<Numeric>) => boolean;
502
506
  * @param val
503
507
  */
504
508
  declare const isTel: (val: NullOrUndefinable<Numeric>) => boolean;
509
+ /**
510
+ * 是否是邮箱
511
+ * @param val
512
+ */
513
+ declare const isEmail: (val: NullOrUndefinable<string>) => boolean;
514
+ /**
515
+ * 是否是身份证
516
+ * @param val 身份证号
517
+ */
518
+ declare const isIdCard: (val: NullOrUndefinable<string>) => boolean;
519
+ /**
520
+ * 包含非ASCII字符
521
+ * @param text
522
+ */
523
+ declare const nonASCII: (text: string) => boolean;
505
524
  /**
506
525
  * 校验接口返回内容
507
526
  * @param res
@@ -518,4 +537,4 @@ declare const isValidArrRes: (res: Res<any[]>) => boolean;
518
537
  */
519
538
  declare const isValidPageRes: (res: PageRes) => boolean;
520
539
 
521
- export { NullOrUndefinable, Nullable, Numeric, Undefinable, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, filterObj, fixiOSInputAutoZoomIn, getHostEnv, hideCardNo, hideMiddle, hideName, hidePhone, hideThird, isArrStr, isDef, isJSONStr, isNumeric, isPhone, isTel, isValidArrRes, isValidKey, isValidPageRes, isValidRes, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, replacer, reviver, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, userAgent, waitTime };
540
+ export { NullOrUndefinable, Nullable, Numeric, PageRes, PageResData, Res, Undefinable, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, filterObj, fixiOSInputAutoZoomIn, getHostEnv, hideCardNo, hideMiddle, hideName, hidePhone, hideThird, isArrStr, isDef, isEmail, isIdCard, isJSONStr, isNumeric, isPhone, isTel, isValidArrRes, isValidKey, isValidPageRes, isValidRes, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, replacer, reviver, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, userAgent, waitTime };
package/dist/index.mjs CHANGED
@@ -83,6 +83,20 @@ const isTel = (val) => {
83
83
  return false;
84
84
  return cnTelRE.test(val.toString());
85
85
  };
86
+ const isEmail = (val) => {
87
+ if (!isDef(val))
88
+ return false;
89
+ const reg = /^[a-zA-Z\d](?:\w|-)+@[a-zA-Z\d]+\.[a-zA-Z]{2,5}$/;
90
+ return reg.test(val);
91
+ };
92
+ const isIdCard = (val) => {
93
+ if (!isDef(val))
94
+ return false;
95
+ const card15 = /^[1-9]\d{7}(?:0[1-9]|10|11|12)(?:[0-2][1-9]|10|20|30|31)\d{2}[\dXx]$/;
96
+ const card18 = /^[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}[\dXx]$/;
97
+ return card15.test(val) || card18.test(val);
98
+ };
99
+ const nonASCII = (text) => /[^\x20-\x7E]/.test(text);
86
100
  const isValidRes = (res) => res.code === 200 && res.data;
87
101
  const isValidArrRes = (res) => res.code === 200 && Array.isArray(res.data);
88
102
  const isValidPageRes = (res) => res.code === 200 && res.data && Array.isArray(res.data.list || res.data.records);
@@ -215,4 +229,4 @@ const reviver = (_, value) => {
215
229
  };
216
230
  const filterObj = (obj, keys, reverse = false) => Object.fromEntries(Object.entries(obj).filter(([key]) => reverse ? !keys.includes(key) : keys.includes(key)));
217
231
 
218
- export { camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, filterObj, fixiOSInputAutoZoomIn, getHostEnv, hideCardNo, hideMiddle, hideName, hidePhone, hideThird, isArrStr, isDef, isJSONStr, isNumeric, isPhone, isTel, isValidArrRes, isValidKey, isValidPageRes, isValidRes, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, replacer, reviver, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, userAgent, waitTime };
232
+ export { camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, filterObj, fixiOSInputAutoZoomIn, getHostEnv, hideCardNo, hideMiddle, hideName, hidePhone, hideThird, isArrStr, isDef, isEmail, isIdCard, isJSONStr, isNumeric, isPhone, isTel, isValidArrRes, isValidKey, isValidPageRes, isValidRes, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, replacer, reviver, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, userAgent, waitTime };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jhqn/utils-core",
3
3
  "type": "module",
4
- "version": "0.0.1-beta.12",
4
+ "version": "0.0.1-beta.13",
5
5
  "author": "jade-gjz <jiangang.zhang@jaderd.com>",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/jaderd-jh/utils/tree/main/packages/core#readme",