Skip to content

Conversation

@yoyo837
Copy link
Member

@yoyo837 yoyo837 commented Oct 29, 2025

Summary by CodeRabbit

发布说明

  • 错误修复
    • 优化了验证逻辑,确保仅在值为有效非空数组时执行子规则验证,防止了对无效值进行不必要的递归验证,提升了验证流程的稳定性。

@vercel
Copy link

vercel bot commented Oct 29, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
field-form Ready Ready Preview Comment Oct 29, 2025 4:24am

@coderabbitai
Copy link

coderabbitai bot commented Oct 29, 2025

总体概览

修改了 src/utils/validateUtil.ts 中的条件验证逻辑,在执行子规则验证前增加了对值是否为非空数组的检查,防止对空数组或非数组值进行递归验证。

变更详情

队列 / 文件 变更摘要
验证条件增强
src/utils/validateUtil.ts
紧化了父规则类型为数组且具有 defaultField 时的子规则验证条件。新增 Array.isArray(value) && value.length > 0 检查,确保仅在值为非空数组时才执行递归验证,跳过对空数组或非数组值的验证。

预估代码审查工作量

🎯 1 (微小) | ⏱️ ~3 分钟

  • 单一文件的局部变更,逻辑修改明确且范围集中
  • 需验证条件变化是否符合预期的验证流程

可能相关的 PR

诗歌

🐰 数组检查更周密,
空值不复来困扰,
验证规则更合理,
递归流程更清爽!✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title Check ❓ Inconclusive PR 标题为 "merge",这是一个非常模糊和通用的术语,完全没有描述实际的代码变更内容。根据变更摘要,本 PR 的核心改动是对 validateUtil.ts 中数组类型规则的子规则验证条件进行了收紧,要求值必须是包含至少一个元素的数组。然而,标题 "merge" 没有传达任何关于这些具体变更的信息,不符合"清晰且具体总结主要变更"的要求,也无法帮助团队成员在扫描历史记录时理解这个 PR 的核心改动。 建议将 PR 标题修改为更加具体和描述性的内容,例如 "Fix array validation condition in validateUtil" 或 "Tighten sub-rule validation for array type rules",以便清晰反映这次变更的实际目的和影响范围。
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch antd-5.x

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1ee67d8 and 341eb4a.

📒 Files selected for processing (1)
  • src/utils/validateUtil.ts (1 hunks)
🔇 Additional comments (1)
src/utils/validateUtil.ts (1)

93-101: 代码改动正确,且已有相应测试覆盖。

验证结果确认:

  1. 现有测试覆盖边界情况:测试用例 antd issue #36436 明确验证了当表单字段未初始化时(valueundefined 或非数组类型)的场景。此测试预期 validateFields() 不应抛出错误。

  2. Array.isArray(value) 检查是必需的:该检查防止在第 95 行对非数组值调用 .map() 导致的 TypeError。没有此检查,第 36436 号 issue 的场景会失败。

  3. value.length > 0 检查的合理性:跳过空数组的子规则验证既是性能优化,也避免了不必要的异步操作。

这些改动不仅提升了代码健壮性,更重要的是修复了已报告的bug。现有测试套件已充分验证这些边界情况。


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @yoyo837, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a minor but important refinement to the validation utility. The change specifically targets the validateRule function, ensuring that recursive sub-rule validation logic is only executed when the target value is confirmed to be a non-empty array. This enhancement likely improves the robustness and efficiency of the validation process by avoiding attempts to iterate over non-array or empty data structures.

Highlights

  • Validation Logic Enhancement: Improved the validateRule function by adding a condition to ensure that sub-rule validation is only attempted when the value being processed is an array and contains elements. This prevents unnecessary processing or potential errors when value is not an array or is empty.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov
Copy link

codecov bot commented Oct 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.61%. Comparing base (f9ac280) to head (341eb4a).
⚠️ Report is 21 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #766      +/-   ##
==========================================
+ Coverage   99.44%   99.61%   +0.16%     
==========================================
  Files          18       19       +1     
  Lines        1257     1799     +542     
  Branches      315      501     +186     
==========================================
+ Hits         1250     1792     +542     
  Misses          7        7              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a crucial validation check in the validateRule function. By adding Array.isArray(value) && value.length > 0 to the condition for recursive validation of array fields, it prevents a potential runtime error that could occur if a non-array value is passed for a field with type: 'array'. This is a solid bug fix that improves the robustness of the validation logic. The change is correct and well-implemented.

@yoyo837 yoyo837 merged commit 0ec1a4e into master Oct 29, 2025
13 checks passed
@yoyo837 yoyo837 deleted the antd-5.x branch October 29, 2025 04:28
@zombieJ zombieJ restored the antd-5.x branch October 29, 2025 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants