From eca8ad86e55d52f2c7214338d6b2ab245dd7f57a Mon Sep 17 00:00:00 2001 From: oasis-cloud Date: Wed, 3 Jul 2024 10:52:00 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(form):=20validator=20=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=20value=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 } From 82be780a386a577eaeef8d0b3a87dc42b3b41161 Mon Sep 17 00:00:00 2001 From: oasis-cloud Date: Wed, 3 Jul 2024 10:55:04 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(form):=20validator=20=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=20value=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/h5/demo1.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/packages/form/demos/h5/demo1.tsx b/src/packages/form/demos/h5/demo1.tsx index dd0551953f..dd6a3b408b 100644 --- a/src/packages/form/demos/h5/demo1.tsx +++ b/src/packages/form/demos/h5/demo1.tsx @@ -1,5 +1,6 @@ import React from 'react' import { Form, Button, InputNumber, Input, TextArea } from '@nutui/nutui-react' +import { FormItemRuleWithoutValidator } from '@/packages/formitem/types' const Demo1 = () => { return ( @@ -21,6 +22,14 @@ const Demo1 = () => { rules={[ { max: 5, message: '字段A不能超过5个字' }, { required: true, message: '请输入字段A' }, + { + validator: ( + ruleCfg: FormItemRuleWithoutValidator, + value: string + ) => { + return value.length > 5 + }, + }, ]} >