viclafouch / mui-tel-input

📌 A phone number input designed for MUI (Material ui) V6 built with libphonenumber-js
https://viclafouch.github.io/mui-tel-input
MIT License
158 stars 65 forks source link

matchIsValidTel incorrect CN validation #149

Closed fxavierho123 closed 2 months ago

fxavierho123 commented 2 months ago

input:

console.log("7 digit CN number: +86 1234567, ", 
  matchIsValidTel("+86 1234567", { onlyCountries: ['CN'] })
);

console.log("8 digit CN number: +86 12345678, ", 
  matchIsValidTel("+86 12345678", { onlyCountries: ['CN'] })
);

console.log("9 digit CN number: +86 123456789, ", 
  matchIsValidTel("+86 123456789", { onlyCountries: ['CN'] })
);

console.log("10 digit CN number: +86 1234567890, ", 
  matchIsValidTel("+86 1234567890", { onlyCountries: ['CN'] })
);

console.log("11 digit CN number: +86 12345678901, ", 
  matchIsValidTel("+86 12345678901", { onlyCountries: ['CN'] })
);

console.log("12 digit CN number: +86 123456789012, ", 
  matchIsValidTel("+86 123456789012", { onlyCountries: ['CN'] })
);

console.log("12 digit CN number: +86 131123456789, ", 
  matchIsValidTel("+86 131123456789", { onlyCountries: ['CN'] })
);

output: image

expected output: Only 11 digit should return true

viclafouch commented 2 months ago

Helllo !

matchIsValidTel is using https://www.npmjs.com/package/libphonenumber-js under the hood, with the isValidPhoneNumber function. So you should create an issue with this package.