util-helpers 4.10.2 → 4.10.3

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.
@@ -500,7 +500,7 @@
500
500
  * @since 1.1.0
501
501
  * @param {*} value 要检测的值
502
502
  * @param {Object} [options] 配置项
503
- * @param {boolean} [options.loose=false] 宽松模式。如果为true,不校验校验位。
503
+ * @param {boolean} [options.checkCode=true] 是否校验最后一位校验码,如果为false,不校验校验位。
504
504
  * @returns {boolean} 值是否为统一社会信用代码
505
505
  * @example
506
506
  *
@@ -510,18 +510,25 @@
510
510
  * isSocialCreditCode('91350100M000100Y4A');
511
511
  * // => false
512
512
  *
513
- * // 宽松模式,不校验校验位。所以也可以通过
514
- * isSocialCreditCode('91350100M000100Y4A', {loose: true});
513
+ * // 不校验校验位
514
+ * isSocialCreditCode('91350100M000100Y4A', { checkCode: false });
515
515
  * // => true
516
516
  *
517
+ * isSocialCreditCode('91350100M000100Y', { checkCode: false });
518
+ * // => false
519
+ *
517
520
  */
518
- function isSocialCreditCode(value, { loose = false } = {}) {
521
+ function isSocialCreditCode(value, options = {}) {
519
522
  const valueStr = normalizeString(value);
523
+ // @ts-ignore
524
+ // TODO 下个版本废弃 loose
525
+ const { loose = false, checkCode: cc = true } = options;
526
+ const needCheckCode = !loose && cc;
520
527
 
521
528
  const passBaseRule = baseReg$1.test(valueStr);
522
529
 
523
530
  // 宽松模式 或 基础规则不通过直接返回
524
- if (loose || !passBaseRule) {
531
+ if (!needCheckCode || !passBaseRule) {
525
532
  return passBaseRule;
526
533
  }
527
534
 
@@ -1121,32 +1128,33 @@
1121
1128
  * @since 3.5.0
1122
1129
  * @param {*} value 要检测的值
1123
1130
  * @param {Object} [options] 配置项
1124
- * @param {boolean} [options.loose=false] 宽松模式。如果为true,不校验校验位。
1131
+ * @param {boolean} [options.checkCode=true] 是否校验最后一位校验码,如果为false,不校验校验位。
1125
1132
  * @returns {boolean} 值是否为营业执照号
1126
1133
  * @example
1127
1134
  *
1128
1135
  * isBusinessLicense('310115600985533');
1129
1136
  * // => true
1130
1137
  *
1131
- * isBusinessLicense('3101156009');
1132
- * // => false
1133
- *
1134
- * isBusinessLicense('3101156009', { loose: true });
1135
- * // => false
1136
- *
1137
1138
  * isBusinessLicense('310115600985535');
1138
1139
  * // => false
1139
1140
  *
1140
- * isBusinessLicense('310115600985535', { loose: true });
1141
+ * isBusinessLicense('310115600985535', { checkCode: false });
1141
1142
  * // => true
1143
+ *
1144
+ * isBusinessLicense('31011560098', { checkCode: false });
1145
+ * // => false
1142
1146
  */
1143
- function isBusinessLicense(value, { loose = false } = {}) {
1147
+ function isBusinessLicense(value, options = {}) {
1144
1148
  const valueStr = normalizeString(value);
1149
+ // @ts-ignore
1150
+ // TODO 下个版本废弃 loose
1151
+ const { loose = false, checkCode: cc = true } = options;
1152
+ const needCheckCode = !loose && cc;
1145
1153
 
1146
1154
  const passBaseRule = baseReg.test(valueStr);
1147
1155
 
1148
1156
  // 宽松模式 或 基础规则不通过直接返回
1149
- if (loose || !passBaseRule) {
1157
+ if (!needCheckCode || !passBaseRule) {
1150
1158
  return passBaseRule;
1151
1159
  }
1152
1160