catamphetamine / libphonenumber-js

A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript
https://catamphetamine.gitlab.io/libphonenumber-js/
MIT License
2.76k stars 218 forks source link

Unable to get Number Type of some numbers like Indian Mobile Numbers #455

Closed tahseen0amin closed 6 months ago

tahseen0amin commented 6 months ago

I am getting NumberType as undefined for some of the following numbers:

  1. 9821121775 - IN
  2. 1234567899 - IN

But in the google libphonenumber return the correct Number Type. https://libphonenumber.appspot.com/phonenumberparser?number=9821121775&country=IN

catamphetamine commented 6 months ago

Most likely you’re not using max metadata

On Sat, 3 Feb 2024 at 12:28, Tasin Zarkoob @.***> wrote:

I am getting NumberType as undefined for some of the following numbers:

  1. 9821121775 - IN
  2. 1234567899 - IN

But in the google libphonenumber return the correct Number Type.

https://libphonenumber.appspot.com/phonenumberparser?number=9821121775&country=IN

— Reply to this email directly, view it on GitHub https://github.com/catamphetamine/libphonenumber-js/issues/455, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADUP35RFTVIAE7RZ4NHVVLYRX7NNAVCNFSM6AAAAABCX4DEC2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGEYTMMZYGMZDGNI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

tahseen0amin commented 6 months ago

How do we do that?

This is how I am using it

import { parsePhoneNumberWithError } from 'libphonenumber-js';

const phoneNumberObj = parsePhoneNumberWithError(
        phoneNumber,
        selectedCountryAbbr,
      );
valid = phoneNumberObj.isValid();
const type = phoneNumberObj.getType();
if (type && type !== 'MOBILE') {
    valid = false;
}

Where do I need to change that.

catamphetamine commented 6 months ago

from 'libphonenumber-js/max'

tahseen0amin commented 6 months ago

Thanks.

Closing this issue.