feat(form): requires Increase function type value (#649)

* feat(form): requires Increase function type value

* feat(form): requires Increase function type value

* fix(form): 修复 rules 赋值错误的问题
This commit is contained in:
Mikasa33 2021-05-25 01:17:32 +08:00 committed by GitHub
parent bbf178f64b
commit 765064a190
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -174,8 +174,12 @@
return Promise.resolve();
}
if ((!rules || rules.length === 0) && required) {
rules = [{ required, validator }];
const getRequired = isFunction(required)
? required(unref(getValues))
: required;
if ((!rules || rules.length === 0) && getRequired) {
rules = [{ required: getRequired, validator }];
}
const requiredRuleIndex: number = rules.findIndex(

View File

@ -149,7 +149,7 @@ export interface FormSchema {
}) => Recordable)
| object;
// Required
required?: boolean;
required?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean);
suffix?: string | number | ((values: RenderCallbackParams) => string | number);