-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
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
fix(form): validator 中的 value 类型更新为 any #2406
Conversation
Walkthrough此次更改的核心在于修正和改进表单验证功能。主要包括为表单规则添加新的验证器函数,以及在 Changes
Sequence Diagram(s)不适用于此次变更。 Possibly related issues
Poem
Tip AI model upgrade
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## next #2406 +/- ##
==========================================
+ Coverage 85.96% 85.98% +0.02%
==========================================
Files 217 217
Lines 22828 22828
Branches 2537 2540 +3
==========================================
+ Hits 19623 19629 +6
+ Misses 3200 3194 -6
Partials 5 5 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
{ | ||
validator: ( | ||
ruleCfg: FormItemRuleWithoutValidator, | ||
value: string | ||
) => { | ||
return value.length > 5 | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
请更新验证器函数中的 value
类型。
验证器函数中的 value
类型应与 FormItemRule
接口中的更新保持一致。
- value: string
+ value: any
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
{ | |
validator: ( | |
ruleCfg: FormItemRuleWithoutValidator, | |
value: string | |
) => { | |
return value.length > 5 | |
}, | |
}, | |
{ | |
validator: ( | |
ruleCfg: FormItemRuleWithoutValidator, | |
value: any | |
) => { | |
return value.length > 5 | |
}, | |
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
{ | ||
validator: ( | ||
ruleCfg: FormItemRuleWithoutValidator, | ||
value: string | ||
) => { | ||
return value.length > 5 | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
验证函数的实现需要改进。
- 验证函数的
value
参数类型应该与FormItemRule
接口中的更新保持一致,即any
类型。 - 验证函数返回布尔值,但没有提供错误消息。应该使用
callback
函数返回错误消息。
{
- validator: (
- ruleCfg: FormItemRuleWithoutValidator,
- value: string
- ) => {
- return value.length > 5
- },
+ validator: (
+ ruleCfg: FormItemRuleWithoutValidator,
+ value: any,
+ callback: (error?: string) => void
+ ) => {
+ if (value.length > 5) {
+ callback('字段A不能超过5个字');
+ } else {
+ callback();
+ }
+ },
},
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
{ | |
validator: ( | |
ruleCfg: FormItemRuleWithoutValidator, | |
value: string | |
) => { | |
return value.length > 5 | |
}, | |
}, | |
{ | |
validator: ( | |
ruleCfg: FormItemRuleWithoutValidator, | |
value: any, | |
callback: (error?: string) => void | |
) => { | |
if (value.length > 5) { | |
callback('字段A不能超过5个字'); | |
} else { | |
callback(); | |
} | |
}, | |
}, |
🤔 这个变动的性质是?
🔗 相关 Issue
#2339
Summary by CodeRabbit
新功能
改进