@signalplus/params-about 0.1.27 → 0.1.28

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/index.d.ts CHANGED
@@ -77,6 +77,7 @@ interface ParamFormData {
77
77
  }
78
78
  interface ParamFormProps {
79
79
  parentOptions: ParentSelectorProps['parentOptions'];
80
+ allKeys: string[];
80
81
  expiriesOptions: string[];
81
82
  initialValues?: Partial<ParamFormData>;
82
83
  groupEditable?: boolean;
@@ -308,7 +309,7 @@ declare function numRangeValidator(val: {
308
309
  }, enableEmpty?: boolean): string;
309
310
  declare function expiryValidator(val: string, enableEmpty?: boolean): "Should not be empty" | "" | "Out of format";
310
311
  declare function expiriesValidator(val: string[]): string;
311
- declare function keyValidator(val: string): "Should not be empty" | "" | "Out of format: should be a combination of the following chars `_.0-9a-zA-Z`";
312
+ declare function keyValidator(val: string, allKeys: string[]): "Should not be empty" | "" | "Out of format: should be a combination of the following chars `_.0-9a-zA-Z`" | "This key has been used";
312
313
  declare function isExpired(val?: string): boolean;
313
314
  declare function validatorCvt(validator: (val: any, values: any) => ValidateInfo['string'], form?: () => any): (_: any, val: any) => Promise<any>;
314
315
 
package/lib/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Bundle of @signalplus/params-about
3
3
  * Generated: 2022-04-12
4
- * Version: 0.1.27
4
+ * Version: 0.1.28
5
5
  * License: MIT
6
6
  * Author: 2631541504@qq.com
7
7
  */
@@ -409,10 +409,19 @@ function expiriesValidator(val) {
409
409
 
410
410
  return '';
411
411
  }
412
- function keyValidator(val) {
412
+ function keyValidator(val, allKeys) {
413
413
  var error = emptyValidator(val);
414
414
  if (error) return error;
415
- return /^[_.a-zA-Z0-9]+$/.test(val) ? '' : 'Out of format: should be a combination of the following chars `_.0-9a-zA-Z`';
415
+
416
+ if (/^[_.a-zA-Z0-9]+$/.test(val)) {
417
+ return 'Out of format: should be a combination of the following chars `_.0-9a-zA-Z`';
418
+ }
419
+
420
+ var has = allKeys.some(function (it) {
421
+ return val === it;
422
+ });
423
+ if (has) return 'This key has been used';
424
+ return '';
416
425
  }
417
426
  function isExpired(val) {
418
427
  if (!val) return false;
@@ -1403,7 +1412,9 @@ var ParamForm = /*#__PURE__*/function (_PureComponent) {
1403
1412
  }, props));
1404
1413
  },
1405
1414
  required: true,
1406
- validator: validatorCvt(keyValidator)
1415
+ validator: validatorCvt(function (val) {
1416
+ return keyValidator(val, _this2.props.allKeys);
1417
+ })
1407
1418
  }, {
1408
1419
  label: '参数名称',
1409
1420
  name: 'name',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalplus/params-about",
3
- "version": "0.1.27",
3
+ "version": "0.1.28",
4
4
  "description": "A description for the module",
5
5
  "main": "./lib/umd/index.js",
6
6
  "module": "./lib/es/index.js",