【发布时间】:2021-11-23 15:22:59
【问题描述】:
我有两个输入,一个带有国家代码选项,例如 CA、US 等,另一个带有手机号码。我在一些源代码中看到使用 google-libphonenumber 进行验证,我在 Use google-libphonenumber in angular reactive forms validator 中找到了一个自定义验证,使用这个自定义验证器会给我带来一些错误返回 validNumber 吗? null : { 'wrongNumber': { value: control.value } };
输入 '{ wrongNumber: { value: any; }; } | null' 不能分配给类型 '{ [key: string]: any; }'。 类型 'null' 不能分配给类型 '{ [key: string]: any; }'。
如何传递国家代码和手机号码进行验证,如果无效则在 html 传递中显示错误。
【问题讨论】: