feat: add ValidationHandler to JSONSchema for fail-safe error collection, for issue #3912#3968
Open
jujn wants to merge 5 commits intoalibaba:mainfrom
Open
feat: add ValidationHandler to JSONSchema for fail-safe error collection, for issue #3912#3968jujn wants to merge 5 commits intoalibaba:mainfrom
jujn wants to merge 5 commits intoalibaba:mainfrom
Conversation
|
@MonkeyCode-AI review 一下 |
|
MonkeyCode-AI 正在分析任务... |
MonkeyCode-AI
left a comment
There was a problem hiding this comment.
我是 MonkeyCode AI 编程助手,你可以在 GitHub 仓库的 PR 中 at @MonkeyCode-AI 来呼唤我。
任务执行细节请参考: https://monkeycode-ai.com/tasks/public?id=51e2b2b6-be8e-42e2-82bd-298457dcc212
代码审查结果
本 PR 通过引入 ValidationHandler 让 Fail-Safe/Fail-Fast 并存且测试较完善,但仍存在组合校验绕过 handler、错误封装不一致与可诊断性不足等问题,建议修复后再合入。
✨ 代码亮点
- 通过 ValidationHandler + abort 标志实现 Fail-Safe / Fail-Fast 双模式,API 简洁直观
- JSONSchema.handleError 将 custom error message 解析与 handler 回调集中封装,降低各 Schema 重复逻辑
- 新增 Issue3912 单元测试覆盖了收集全部错误、提前中断、嵌套对象/数组、dependentRequired、additionalProperties、uniqueItems 等关键场景
| 🚨 Critical | 💡 Suggestion | |
|---|---|---|
| 1 | 0 | 0 |
wenshao
reviewed
Apr 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it?
在 JSONSchema 加入 ValidationHandler 以支持全量错误收集(已支持全量收集自定义错误信息),通过回调机制允许用户控制校验流程(中断/继续)。
代码示例:
使用示例①
使用示例②(Web请求校验)
Summary of your change