We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
问题:在使用antd的Form.Item组件遇到,输入校验错误会输出undefined,问题代码如下: <Form.Item name={'demo'} label={'demo'} rules={[ { validator: (rule, value) => { if (!value) { return Promise.reject('${example}'); } return Promise.resolve(); }, }, ]}
问题原因:查阅了代码发现validateUtil.ts这个文件的replaceMessage函数对'${}'字符串做了特殊处理,但是TS校验没有暴露出来这个处理。
解决:修改代码为如下,可以解决问题 <Form.Item name={'demo'} label={'demo'} rules={[ { validator: (rule, value) => { if (!value) { return Promise.reject('${example}'); } return Promise.resolve(); }, example: '${example}', }, ]}
The text was updated successfully, but these errors were encountered:
+1
Sorry, something went wrong.
辛苦带复现到antd开一个issue.
No branches or pull requests
问题:在使用antd的Form.Item组件遇到,输入校验错误会输出undefined,问题代码如下:
<Form.Item
name={'demo'}
label={'demo'}
rules={[
{
validator: (rule, value) => {
if (!value) {
return Promise.reject('${example}');
}
return Promise.resolve();
},
},
]}
问题原因:查阅了代码发现validateUtil.ts这个文件的replaceMessage函数对'${}'字符串做了特殊处理,但是TS校验没有暴露出来这个处理。
解决:修改代码为如下,可以解决问题
<Form.Item
name={'demo'}
label={'demo'}
rules={[
{
validator: (rule, value) => {
if (!value) {
return Promise.reject('${example}');
}
return Promise.resolve();
},
example: '${example}',
},
]}
The text was updated successfully, but these errors were encountered: