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.79k stars 216 forks source link

isNumberMatch Missing #370

Closed danwhite-ipc closed 4 years ago

danwhite-ipc commented 4 years ago

Which version of the libphonenumber api is this a rewrite of?

catamphetamine commented 4 years ago

This library doesn't provide all functions available in Google's libphonenumber. What is the scenario for using isNumberMatch() in a real application?

catamphetamine commented 4 years ago
/**
   * Takes two phone numbers and compares them for equality.
   *
   * <p>Returns EXACT_MATCH if the country_code, NSN, presence of a leading zero for Italian numbers
   * and any extension present are the same.
   * Returns NSN_MATCH if either or both has no region specified, and the NSNs and extensions are
   * the same.
   * Returns SHORT_NSN_MATCH if either or both has no region specified, or the region specified is
   * the same, and one NSN could be a shorter version of the other number. This includes the case
   * where one has an extension specified, and the other does not.
   * Returns NO_MATCH otherwise.
   * For example, the numbers +1 345 657 1234 and 657 1234 are a SHORT_NSN_MATCH.
   * The numbers +1 345 657 1234 and 345 657 are a NO_MATCH.
   *
   * @param firstNumberIn  first number to compare
   * @param secondNumberIn  second number to compare
   *
   * @return  NO_MATCH, SHORT_NSN_MATCH, NSN_MATCH or EXACT_MATCH depending on the level of equality
   *     of the two numbers, described in the method definition.
   */

I don't see how such a function could be used in a real application. I've added .isEqual() function to PhoneNumber: I guess that would suffice.

danwhite-ipc commented 4 years ago

I have a phone number and a list of contacts, I am looking for a way to find a contact by phone number which takes into consideration potential differences in format or inclusion of international code etc

catamphetamine commented 4 years ago

I see. Use the new isEqual() method then.

On Tue, 4 Feb 2020 at 12:20, Dan White notifications@github.com wrote:

I have a phone number and a list of contacts, I am looking for a way to find a contact by phone number which takes into consideration potential differences in format or inclusion of international code etc

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/catamphetamine/libphonenumber-js/issues/370?email_source=notifications&email_token=AADUP3YZ2MY7KZ572AHMM7DRBEXN3A5CNFSM4KPHXKE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKW4ULQ#issuecomment-581814830, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADUP37TYRESNB2SK6JQJQLRBEXN3ANCNFSM4KPHXKEQ .