Skip to content
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: Form support validateOnly #42273

Merged
merged 2 commits into from
May 11, 2023
Merged

feat: Form support validateOnly #42273

merged 2 commits into from
May 11, 2023

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented May 11, 2023

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Workflow
  • Other (about what?)

🔗 Related issue link

resolve #41801

💡 Background and solution

📝 Changelog

Language Changelog
🇺🇸 English Form validateFields support validateOnly to not to update UI status.
🇨🇳 Chinese Form validateFields 支持 validateOnly 配置仅做校验而不改变 UI 状态。

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

🚀 Summary

🤖 Generated by Copilot at 434a06e

This pull request enhances the Form component by adding a new demo and updating the documentation for the validateFields method. It also updates the rc-field-form dependency to the latest version.

🔍 Walkthrough

🤖 Generated by Copilot at 434a06e

  • Add a new demo for the Form component to demonstrate the validateOnly option of the validateFields method (link, link, link, link)
  • Update the documentation for the Form component to include the { validateOnly?: boolean } parameter for the validateFields method and its version availability (link, link)
  • Bump the dependency version of rc-field-form in package.json to use the latest features of the form library (link)

@github-actions
Copy link
Contributor

github-actions bot commented May 11, 2023

() => {
setSubmittable(true);
},
() => {
Copy link
Member

Choose a reason for hiding this comment

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

感觉第二个参数放进 catch 更直观一点

Copy link
Member Author

Choose a reason for hiding this comment

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

这边是为了防止开发者在 then 里搞了花活导致失败,这么写方便复制过去。

form.validateFields({ validateOnly: true })
  .then(() => {
    // 花活结果搞挂了,会传到下面的 catch 里,以为是校验失败了
    throw new Error(...);
  }).catch(() => { ... });

@github-actions
Copy link
Contributor

github-actions bot commented May 11, 2023

size-limit report 📦

Path Size
./dist/antd.min.js 377.36 KB (+26 B 🔺)
./dist/antd-with-locales.min.js 436.65 KB (+35 B 🔺)

@codecov
Copy link

codecov bot commented May 11, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (c76d9fe) 100.00% compared to head (4e6702d) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##           feature    #42273   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          619       619           
  Lines        10570     10570           
  Branches      2886      2886           
=========================================
  Hits         10570     10570           

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@zombieJ zombieJ merged commit 0ead943 into feature May 11, 2023
87 checks passed
@zombieJ zombieJ deleted the form-validate branch May 11, 2023 07:43
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.

None yet

2 participants