<Form.Item label="Name" name="name" validateTrigger="onBlur" rules={[ { required: true, message: "Please input your name!" }, { validator: checkName, }, ]} > <Input placeholder="Maximum 15 characters" maxLength={15} /> </Form.Item>
// 方法 // 檢視名稱是否重複 const checkName = (_: any, value: any) => { console.log(value); if (value) { return Promise.reject("重複"); } else { return Promise.reject(""); } };
validateTrigger="onBlur"