fix: 🐛 修复 Form 表单 validator 校验不通过且未指定错误信息时无法显示校验信息的问题#791
fix: 🐛 修复 Form 表单 validator 校验不通过且未指定错误信息时无法显示校验信息的问题#791Moonofweisheng merged 1 commit intomasterfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
变更概览演练在 变更
相关可能的 PR
诗歌
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for wot-design-uni ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Deploying wot-design-uni with
|
| Latest commit: |
6ee7bff
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://cf3456d3.wot-design-uni.pages.dev |
| Branch Preview URL: | https://fix-form-validator-error.wot-design-uni.pages.dev |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/uni_modules/wot-design-uni/components/wd-form/wd-form.vue (1)
97-99: 优化了验证错误信息的处理逻辑错误处理逻辑的改进:
- 使用
isDef检查确保错误对象存在- 使用
isString判断错误类型- 提供合理的降级策略,确保始终显示有效的错误信息
这个修改很好地解决了 PR 中描述的问题,即在未指定错误信息时无法显示校验信息的问题。
建议添加单元测试以验证以下场景:
- 抛出字符串类型的错误
- 抛出 Error 对象但没有 message
- 抛出 undefined 错误
需要我帮您编写这些测试用例吗?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/uni_modules/wot-design-uni/components/wd-form/wd-form.vue(2 hunks)
🔇 Additional comments (1)
src/uni_modules/wot-design-uni/components/wd-form/wd-form.vue (1)
22-22: 导入 isString 工具函数以增强类型检查
引入 isString 工具函数有助于更好地处理错误消息的类型判断,使代码更加健壮。
🤔 这个 PR 的性质是?(至少选择一个)
🔗 相关 Issue
💡 需求背景和解决方案
修复 Form 表单 validator 校验不通过且未指定错误信息时无法显示校验信息的问题
☑️ 请求合并前的自查清单
Summary by CodeRabbit
新功能
方法更新
validate和reset方法,供外部使用。