chore: 自定义组件默认rule校验默认触发逻辑为blur

This commit is contained in:
invalid w 2023-12-13 18:34:02 +08:00
parent 1296590e3a
commit 23b684977c

View File

@ -169,7 +169,6 @@
dynamicRules, dynamicRules,
required, required,
} = props.schema; } = props.schema;
if (isFunction(dynamicRules)) { if (isFunction(dynamicRules)) {
return dynamicRules(unref(getValues)) as ValidationRule[]; return dynamicRules(unref(getValues)) as ValidationRule[];
} }
@ -210,7 +209,6 @@
} }
return Promise.resolve(); return Promise.resolve();
} }
const getRequired = isFunction(required) ? required(unref(getValues)) : required; const getRequired = isFunction(required) ? required(unref(getValues)) : required;
/* /*
@ -220,7 +218,10 @@
*/ */
if (getRequired) { if (getRequired) {
if (!rules || rules.length === 0) { if (!rules || rules.length === 0) {
rules = [{ required: getRequired, validator }]; const trigger = NO_AUTO_LINK_COMPONENTS.includes(component || 'Input')
? 'blur'
: 'change';
rules = [{ required: getRequired, validator, trigger }];
} else { } else {
const requiredIndex: number = rules.findIndex((rule) => Reflect.has(rule, 'required')); const requiredIndex: number = rules.findIndex((rule) => Reflect.has(rule, 'required'));