qidian-shared 1.0.11 → 1.0.12

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.
@@ -11980,6 +11980,18 @@ function setUrlParam(key, value, url, andString, newKey) {
11980
11980
  }
11981
11981
  return urltmp;
11982
11982
  }
11983
+ const validatorRegs = {
11984
+ cellPhone: /^1[3-9]\d{9}$/,
11985
+ telephone: /^\d{7,8}$/,
11986
+ url: /^((blob:)*(https|http|ftp|rtsp|mms|wss)?:\/\/)[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/
11987
+ };
11988
+ function validator(value, type, required = false) {
11989
+ if (type === "empty") return isEmpty(value);
11990
+ const reg = validatorRegs[type];
11991
+ if (!reg) throw new Error(`[validators] No ${type}`);
11992
+ if (required && isEmpty(value)) return null;
11993
+ return reg.test(value);
11994
+ }
11983
11995
  function useServiceLoadMore({
11984
11996
  service,
11985
11997
  manual,
@@ -12385,5 +12397,7 @@ exports.useProxy = useProxy;
12385
12397
  exports.useServiceLoadMore = useServiceLoadMore;
12386
12398
  exports.useServicePagination = useServicePagination;
12387
12399
  exports.useTimer = useTimer;
12400
+ exports.validator = validator;
12401
+ exports.validatorRegs = validatorRegs;
12388
12402
  exports.waitTime = waitTime;
12389
12403
  //# sourceMappingURL=qidian-shared.cjs.js.map