angular 6:npm模块awesome电话号码未验证新电话号码系列

angular 6:npm模块awesome电话号码未验证新电话号码系列,angular,Angular,我正在我当前的项目中使用awesomephonenumber节点模块,并用这个插件验证电话号码 虽然现在我面临的问题是新的电话号码系列在特定地区推出后 电话号码+234801****54未被验证,因此电话号码是正确的 我已尝试将npm模块Aweasome phonenumber更新至最新版本,但也不起作用 “很棒的电话号码”:“^2.24.0” 代码快照: static phnValidate(c: FormControl): ValidationErrors { const num = c.

我正在我当前的项目中使用awesomephonenumber节点模块,并用这个插件验证电话号码

虽然现在我面临的问题是新的电话号码系列在特定地区推出后

电话号码+234801****54未被验证,因此电话号码是正确的

我已尝试将npm模块Aweasome phonenumber更新至最新版本,但也不起作用

“很棒的电话号码”:“^2.24.0”

代码快照:

 static phnValidate(c: FormControl): ValidationErrors {
const num = c.value;
let isValid = false;
const pn = new awesomePhonenumber(num != null ? num : '+91');

if (pn.isValid() && pn.isMobile()) {
  isValid = true
}
const message = {
  'phoneNumber': {
    'message': 'Phone Number is not valid'
  }
};
return isValid ? null : message;
}

错误屏幕截图:


Aweasome phonenumber知道新电话号码的一组模式。如果新类型的数字来自尼日利亚,你基本上只能等到谷歌(因此他们使用的是谷歌的图书馆形式)识别出来。您可以在此处编写问题或请求:

同时,您只能为此类号码填写自己的支票:

...
const pn = new awesomePhonenumber(num != null ? num : '+91');

if (pn.isValid() && pn.isMobile()) {
  isValid = true
}

if (! isValid && /^([a-z0-9]{10,})$/.test(num)) {
  isValid = true
}
^([a-z0-9]{10,})
只是一个例子。您必须根据新类型的数字编写正则表达式