chore: improve form warning (#3641)

This commit is contained in:
zkwolf 2021-02-04 10:48:43 +08:00 committed by GitHub
parent 53f3950b81
commit 4e4b9d6cca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -75,10 +75,15 @@ async function validateRule(
subRuleField = cloneRule.defaultField;
delete cloneRule.defaultField;
}
if (!rule.type && typeof rule.validator !== 'function' && typeof value !== 'string') {
if (
!rule.type &&
typeof rule.validator !== 'function' &&
typeof value !== 'string' &&
typeof value !== 'undefined'
) {
warning(
false,
`Form rules must provide type property when validating a value which is not string type`,
`Form rules must provide type property when validating the form item named [${name}] which is not string type`,
);
}