From eca8ad86e55d52f2c7214338d6b2ab245dd7f57a Mon Sep 17 00:00:00 2001 From: oasis-cloud Date: Wed, 3 Jul 2024 10:52:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(form):=20validator=20=E4=B8=AD=E7=9A=84=20v?= =?UTF-8?q?alue=20=E7=B1=BB=E5=9E=8B=E6=9B=B4=E6=96=B0=E4=B8=BA=20any?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/form/demos/taro/demo1.tsx | 13 +++++++++++-- src/packages/formitem/types.ts | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/packages/form/demos/taro/demo1.tsx b/src/packages/form/demos/taro/demo1.tsx index 35b01241ba..3b8d2143ea 100644 --- a/src/packages/form/demos/taro/demo1.tsx +++ b/src/packages/form/demos/taro/demo1.tsx @@ -1,11 +1,12 @@ import React from 'react' import { - Form, Button, - InputNumber, + Form, Input, + InputNumber, TextArea, } from '@nutui/nutui-react-taro' +import { FormItemRuleWithoutValidator } from '@/packages/formitem/types' const Demo1 = () => { return ( @@ -27,6 +28,14 @@ const Demo1 = () => { rules={[ { max: 5, message: '字段A不能超过5个字' }, { required: true, message: '请输入字段A' }, + { + validator: ( + ruleCfg: FormItemRuleWithoutValidator, + value: string + ) => { + return value.length > 5 + }, + }, ]} > boolean | string | Promise }