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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Minor fix on ValidationRule to match AsyncValidator #21250
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit d0dbc41:
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 161275d:
|
Codecov Report
@@ Coverage Diff @@
## 3.x-stable #21250 +/- ##
===========================================
Coverage 97.82% 97.82%
===========================================
Files 286 286
Lines 7754 7754
Branches 2185 2188 +3
===========================================
Hits 7585 7585
Misses 169 169
Continue to review full report at Codecov.
|
@afc163 @hansololai This change is actually not backward compatible. After upgrading to
|
@Kamahl19 You are right. The type has been restricted to not just any I feel like it is so hard to update any Typescript definitions because any update on Types can be backward incompatible. |
)" This reverts commit f7e7ce9.
馃 This is a ...
馃敆 Related issue link
close #21143
馃挕 Background and solution
In a scenario where one could store the
ValidationRule
and use in both in front end with Antd Form, and also could be used in the back end withasync-validator
alone. The rules could not be shared because the newest versionasync-validator
v3's type definitionRuleItem
link here does not match the ValidationRule defined in Antd v3.After some investigation I found out
rc-form
still depends onasync-validator
, which did not have the Typescript definitions (async validator added Typescript support later). So Antd could not directly reexport theRuleItem
, but have to manually defineValidationRule
. But it is not the same.Without introducing new features, I just corrected some fields on
ValidationRule
to be more consistent with theRuleItem
. Even though theRuleItem
is forasync-validator
v3, it was not changed very much after it was introduced, indicating the RuleItem still works for v1.11.To have
RuleItem
andValidationRule
to be fully assignable, theRuleItem
may also need to be changed.馃摑 Changelog
Changed the ValidationRule
type
andenum
field.鈽戯笍 Self Check before Merge