-
-
Notifications
You must be signed in to change notification settings - Fork 271
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
feat(validateFields): add message to reject error type #748
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
概述演练这个拉取请求引入了对验证错误处理的增强。在 变更
序列图sequenceDiagram
participant User
participant FormStore
participant Validator
User->>FormStore: validateFields()
FormStore->>Validator: 执行字段验证
Validator-->>FormStore: 返回错误列表
FormStore->>FormStore: 提取第一个错误消息
FormStore-->>User: 返回带错误消息的结果
诗歌
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
🔇 Additional comments (1)
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 (
|
return Promise.reject({ | ||
message: errorMessage, |
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.
感觉你可以把错误都列一列,另外没有 test case
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.
如果字段太多的话 message 可能会有过长的问题,另外多个字符串拼在一起,连字符选什么也需要考虑,还要考虑多语言,用中文或英文符号都不是很合适。因此我觉得还是最好只保留第一条,处理起来比较简单。
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.
已补充测试用例
11349b9
to
7497571
Compare
在日常开发中,有时会使用链式 promise 调用:
但是当表单校验失败时,弹出的 message 是空的,因为 validateFields 的 reject 返回并非标准 Error 对象,没有 message 属性。
此 PR 为 validateFields 的 reject 返回增加 message,使其更像一个 Error 对象。在需要展示 popup message 的场景能够更便捷的取值。降低开发者学习和使用的成本。
Summary by CodeRabbit
新功能
Bug 修复
这些更改旨在提供更详细和清晰的验证错误信息,帮助用户更好地理解和解决表单验证问题。