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 + }, + }, ]} > { 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 }