Skip to content

Commit

Permalink
feat(form): requires Increase function type value (#649)
Browse files Browse the repository at this point in the history
* feat(form): requires Increase function type value

* feat(form): requires Increase function type value

* fix(form): 修复 rules 赋值错误的问题
  • Loading branch information
Mikasa33 authored May 24, 2021
1 parent bbf178f commit 765064a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/components/Form/src/components/FormItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/components/Form/src/types/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export interface FormSchema {
}) => Recordable)
| object;
// Required
required?: boolean;
required?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean);

suffix?: string | number | ((values: RenderCallbackParams) => string | number);

Expand Down

0 comments on commit 765064a

Please sign in to comment.