diff --git a/packages/form/src/form-item.vue b/packages/form/src/form-item.vue index 628e8c489..438086aba 100644 --- a/packages/form/src/form-item.vue +++ b/packages/form/src/form-item.vue @@ -148,7 +148,7 @@ methods: { validate(trigger, callback = noop) { var rules = this.getFilteredRule(trigger); - if (!rules || rules.length === 0) { + if ((!rules || rules.length === 0) && !this._props.hasOwnProperty('required')) { callback(); return true; } @@ -194,10 +194,11 @@ getRules() { var formRules = this.form.rules; var selfRules = this.rules; + var requiredRule = this._props.hasOwnProperty('required') ? { required: !!this.required } : []; formRules = formRules ? formRules[this.prop] : []; - return [].concat(selfRules || formRules || []); + return [].concat(selfRules || formRules || []).concat(requiredRule); }, getFilteredRule(trigger) { var rules = this.getRules(); @@ -232,7 +233,7 @@ let rules = this.getRules(); - if (rules.length) { + if (rules.length || this._props.hasOwnProperty('required')) { this.$on('el.form.blur', this.onFieldBlur); this.$on('el.form.change', this.onFieldChange); }