semi-design
semi-design copied to clipboard
[Form] Field use rules validate, when message is empty string, can't resolve or reject
Is there an existing issue for this?
- [X] I have searched the existing issues
Which Component
Form
Semi Version
2.62
Current Behavior
如果用了 FieldProps rules 去指定校验规则,并且 message显式设置为空字符串,即校验不通过,但是校验信息又不希望展示的情况下(属于极端用例,非常规场景),此时校验无法走到 resolve 也无法走到 reject onSubmitFail 和 onSubmit 都无法被触发,如果是formApi.validate 手动触发校验的,此时也无法被resolve 或者reject
Expected Behavior
能正确触发 onSubmitFail 或者 onSubmit
Steps To Reproduce
No response
ReproducibleCode
import React from 'react';
import { Form, Button } from '@douyinfe/semi-ui';
() => {
const initValues = {
name: 'se',
};
const style = { width: '100%' };
const { Select, Input } = Form;
return (
<Form initValues={initValues} onSubmit={()=> Toast.success('success')} onSubmitFail={() => Toast.error('error')}>
<Input
field="name"
style={style}
trigger='custom'
rules={[
{ validator: (rule, value) => value === 'semi', message: '' },
]}
/>
<Button htmlType='submit'>提交</Button>
</Form>
);
};
Environment
- OS:
- browser:
Anything else?
No response