-
-
Notifications
You must be signed in to change notification settings - Fork 921
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(FormControl): support ruleDependencies #3729
base: main
Are you sure you want to change the base?
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
@myNameIsDu is attempting to deploy a commit to the rsuite Team on Vercel. A member of the Team first needs to authorize it. |
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. |
ad71e89
to
c20d7f2
Compare
src/FormControl/FormControl.tsx
Outdated
const checkedErrors = checkFieldNames.reduce((acc, checkFieldName) => { | ||
const checkResult = model?.checkForField(checkFieldName, nextFormValue); | ||
if (checkResult.hasError) { | ||
acc[checkFieldName] = checkResult.errorMessage || checkResult; | ||
} | ||
return acc; | ||
}, {} as Record<string, ReactNode>); | ||
const nextError = { | ||
...omit(formError, checkFieldNames), | ||
...checkedErrors | ||
}; |
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.
This code has a high degree of duplication with the code in then
, and it is best to abstract out the reused code.
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.
done
@@ -193,6 +193,7 @@ cleanErrorForField: (fieldName: keyof E, callback?: () => void) => void; | |||
| plaintext | boolean | Make the control plaintext. | | |||
| readOnly | boolean | Make the control readonly. | | |||
| rule | checkType | Current field verification rule. If it conflicts with the `<Form>`'s `model`, it get higher priority, [example](/components/form-validation/#field-level-verification-rules). | | |||
| ruleDependencies | string[] | The dependent fields for the check. | |
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.
Add version badge:
The dependent fields for the check. <br/>![](https://img.shields.io/badge/min-v5.50.0-blue)
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.
done
@@ -180,8 +180,10 @@ cleanErrorForField: (fieldName: keyof E, callback?: () => void) => void; | |||
| plaintext | boolean | 使控件为纯文本。 | | |||
| readOnly | boolean | 使控件为只读。 | | |||
| rule | checkType | 当前字段的校验规则,如果与`<Form>`的`model`冲突,以当前为准,[示例](/zh/components/form-validation/#field-级别的校验规则)。 | | |||
| ruleDependencies | string[] | 校验依赖的字段。 | |
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.
Add version badge:
校验依赖的字段。 <br/>![](https://img.shields.io/badge/min-v5.50.0-blue)
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.
done
src/FormControl/FormControl.tsx
Outdated
@@ -71,6 +73,9 @@ export interface FormControlProps<P = any, ValueType = any> | |||
|
|||
/** Validation rule */ | |||
rule?: CheckType<unknown, any>; | |||
|
|||
/** The dependent fields for the check */ |
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.
Indicate version
/**
* The dependent fields for the check.
* @version 5.60.0
*/
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.
done
c20d7f2
to
f10b678
Compare
f10b678
to
2fa4eab
Compare
2fa4eab
to
8f77273
Compare
8f77273
to
9b3c1f9
Compare
before
Kapture.2024-04-07.at.17.08.22.mp4
after
Kapture.2024-04-07.at.17.10.41.mp4