From 343e3aa2e4ed11adbf2141abf64f9bff8d915932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B1=E6=98=AF=E5=96=9C=E6=AC=A2=E9=99=88=E7=B2=92?= Date: Sat, 7 Nov 2020 22:54:01 +0800 Subject: [PATCH] fix: add warning when validating form for non-string type (#3128) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 成仕伟 --- components/form/utils/validateUtil.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/form/utils/validateUtil.ts b/components/form/utils/validateUtil.ts index 7cd9c5d4d..88f1504eb 100644 --- a/components/form/utils/validateUtil.ts +++ b/components/form/utils/validateUtil.ts @@ -75,6 +75,12 @@ async function validateRule( subRuleField = cloneRule.defaultField; delete cloneRule.defaultField; } + if (!rule.type && typeof rule.validator !== 'function' && typeof value !== 'string') { + warning( + false, + `Form rules must provide type property when validating a value which is not string type`, + ); + } const validator = new AsyncValidator({ [name]: [cloneRule],