@tmagic/form 1.8.0-beta.21 → 1.8.0-beta.22

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.
@@ -162,6 +162,9 @@ var getRules = function(mForm, r = [], props, typeMatchValid) {
162
162
  }, mForm));
163
163
  }
164
164
  return item;
165
+ }).filter((item) => {
166
+ if (item.typeMatch === false && typeof item.validator !== "function") return false;
167
+ return true;
165
168
  });
166
169
  };
167
170
  var initValue = async (mForm, { initValues, config }) => {
@@ -3368,6 +3368,9 @@
3368
3368
  }, mForm));
3369
3369
  }
3370
3370
  return item;
3371
+ }).filter((item) => {
3372
+ if (item.typeMatch === false && typeof item.validator !== "function") return false;
3373
+ return true;
3371
3374
  });
3372
3375
  };
3373
3376
  var initValue = async (mForm, { initValues, config }) => {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.8.0-beta.21",
2
+ "version": "1.8.0-beta.22",
3
3
  "name": "@tmagic/form",
4
4
  "type": "module",
5
5
  "sideEffects": [
@@ -52,9 +52,9 @@
52
52
  "peerDependencies": {
53
53
  "vue": "^3.5.40",
54
54
  "typescript": "^6.0.3",
55
- "@tmagic/design": "1.8.0-beta.21",
56
- "@tmagic/utils": "1.8.0-beta.21",
57
- "@tmagic/form-schema": "1.8.0-beta.21"
55
+ "@tmagic/utils": "1.8.0-beta.22",
56
+ "@tmagic/design": "1.8.0-beta.22",
57
+ "@tmagic/form-schema": "1.8.0-beta.22"
58
58
  },
59
59
  "peerDependenciesMeta": {
60
60
  "typescript": {
package/src/utils/form.ts CHANGED
@@ -327,39 +327,48 @@ export const getRules = function (
327
327
  });
328
328
  }
329
329
 
330
- return rules.map((item) => {
331
- if (item.typeMatch) {
332
- (item as any).validator = adaptFormValidator(createTypeMatchValidator(mForm, props, item));
333
- return item;
334
- }
330
+ return rules
331
+ .map((item) => {
332
+ if (item.typeMatch) {
333
+ (item as any).validator = adaptFormValidator(createTypeMatchValidator(mForm, props, item));
334
+ return item;
335
+ }
335
336
 
336
- if (typeof item.validator === 'function') {
337
- const fnc = item.validator;
338
-
339
- (item as any).validator = adaptFormValidator(
340
- (rule: any, value: any, callback: Function, source: any, options: any) =>
341
- fnc(
342
- {
343
- rule,
344
- value: props.config.names ? props.model : value,
345
- callback,
346
- source,
347
- options,
348
- },
349
- {
350
- values: mForm?.initValues || {},
351
- model: props.model,
352
- parent: mForm?.parentValues || {},
353
- formValue: mForm?.values || props.model,
354
- prop: props.prop,
355
- config: props.config,
356
- },
357
- mForm,
358
- ),
359
- );
360
- }
361
- return item;
362
- });
337
+ if (typeof item.validator === 'function') {
338
+ const fnc = item.validator;
339
+
340
+ (item as any).validator = adaptFormValidator(
341
+ (rule: any, value: any, callback: Function, source: any, options: any) =>
342
+ fnc(
343
+ {
344
+ rule,
345
+ value: props.config.names ? props.model : value,
346
+ callback,
347
+ source,
348
+ options,
349
+ },
350
+ {
351
+ values: mForm?.initValues || {},
352
+ model: props.model,
353
+ parent: mForm?.parentValues || {},
354
+ formValue: mForm?.values || props.model,
355
+ prop: props.prop,
356
+ config: props.config,
357
+ },
358
+ mForm,
359
+ ),
360
+ );
361
+ }
362
+ return item;
363
+ })
364
+ .filter((item) => {
365
+ // typeMatch: false 仅用于关闭自动注入,本身没有校验能力。
366
+ // 若原样交给 async-validator,会因默认 type=string 误杀 number 等合法值。
367
+ if (item.typeMatch === false && typeof item.validator !== 'function') {
368
+ return false;
369
+ }
370
+ return true;
371
+ });
363
372
  };
364
373
 
365
374
  export const initValue = async (