多个表单控件的条件表达式在@rxweb中不起作用/reactive-form-validators@2.1.2.



我有这个表单

this.customerDetailsFormGroup = this._formBuilder.group({
customer: [this.order.customer_details.name, [RxwebValidators.required({ conditionalExpression: (x) => !this.isNewCustomer })]],
customer_details: this._formBuilder.group({
name: [this.order.customer_details.name, [RxwebValidators.required({
conditionalExpression: (x, y) => {
console.log('name', this.isNewCustomer);
return this.isNewCustomer;
}
}), RxwebValidators.maxLength({ value: 80 })]],
company: [this.order.customer_details.company, [RxwebValidators.maxLength({ value: 100 })]],
email: [this.order.customer_details.email, [RxwebValidators.required({
conditionalExpression: (x, y) => {
console.log('email', this.isNewCustomer);
return this.isNewCustomer;
}
}), RxwebValidators.maxLength({ value: 255 }), RxwebValidators.email()]],
mobile: [this.order.customer_details.mobile, [RxwebValidators.required({
conditionalExpression: (x, y) => {
return this.isNewCustomer;
}
}), RxwebValidators.minLength({ value: 10 }), RxwebValidators.maxLength({ value: 10 })]],
})
});

在这种形式中,我在条件表达式isNewCustomer中有一个变量,这是一个布尔值,我根据它来检查字段是否应该是必需的。

customer_detailsFormGroup中的nameFormControl的isNewCustomer变量值为true时,将验证而不是电子邮件和移动设备。

我尝试登录电子邮件的conditionalExpression,但它不起作用。它似乎不适用于多个条件表达式。

预期行为

所有具有conditionalExpression的FormControls都应该被触发。

我也面临同样的问题,包中有一个问题,现在在最新版本中已经修复。

请更新软件包。

最新更新