From 4e4b9d6ccac3176864fd5815f530820edccdfb09 Mon Sep 17 00:00:00 2001 From: zkwolf Date: Thu, 4 Feb 2021 10:48:43 +0800 Subject: [PATCH] chore: improve form warning (#3641) --- components/form/utils/validateUtil.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/form/utils/validateUtil.ts b/components/form/utils/validateUtil.ts index 88f1504eb..bd8a1c91a 100644 --- a/components/form/utils/validateUtil.ts +++ b/components/form/utils/validateUtil.ts @@ -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`, ); }