Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace google-libphonenumber with libphonenumber-js #89

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3253,11 +3253,6 @@ globals@^12.1.0:
dependencies:
type-fest "^0.8.1"

google-libphonenumber@^3.2.10:
version "3.2.19"
resolved "https://registry.yarnpkg.com/google-libphonenumber/-/google-libphonenumber-3.2.19.tgz#4177f9a1232a740cfd378a46f628ae9a62982069"
integrity sha512-zevRvpUuc88wIXa+ijlMprAc8SrldUtYY2vQpfymmxyZ2ksct6gFrGxccpo28+zjvjK51VoSUaDUHS24XYp6dA==

graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.3, graceful-fs@^4.1.6, graceful-fs@^4.1.9, graceful-fs@^4.2.0, graceful-fs@^4.2.4:
version "4.2.6"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.6.tgz#ff040b2b0853b23c3d31027523706f1885d76bee"
Expand Down Expand Up @@ -4491,6 +4486,11 @@ levn@^0.3.0, levn@~0.3.0:
prelude-ls "~1.1.2"
type-check "~0.3.2"

libphonenumber-js@^1.9.49:
version "1.9.49"
resolved "https://registry.yarnpkg.com/libphonenumber-js/-/libphonenumber-js-1.9.49.tgz#d431703cd699be2ccced5b95f26182a7c50a9227"
integrity sha512-/wEOIONcVboFky+lWlCaF7glm1FhBz11M5PHeCApA+xDdVfmhKjHktHS8KjyGxouV5CSXIr4f3GvLSpJa4qMSg==

lines-and-columns@^1.1.6:
version "1.1.6"
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
Expand Down Expand Up @@ -5600,9 +5600,9 @@ react-native-country-picker-modal@^2.0.0:
react-async-hook "3.6.1"

react-native-phone-number-input@../:
version "2.0.1"
version "2.1.0"
dependencies:
google-libphonenumber "^3.2.10"
libphonenumber-js "^1.9.49"
react-native-country-picker-modal "^2.0.0"

[email protected]:
Expand Down
9 changes: 3 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import CountryPicker, {
CountryModalProvider,
Flag,
} from "react-native-country-picker-modal";
import { PhoneNumberUtil } from "google-libphonenumber";
import { isValidPhoneNumber } from "libphonenumber-js";
import styles from "./styles";

const dropDown =
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAi0lEQVRYR+3WuQ6AIBRE0eHL1T83FBqU5S1szdiY2NyTKcCAzU/Y3AcBXIALcIF0gRPAsehgugDEXnYQrUC88RIgfpuJ+MRrgFmILN4CjEYU4xJgFKIa1wB6Ec24FuBFiHELwIpQxa0ALUId9wAkhCnuBdQQ5ngP4I9wxXsBDyJ9m+8y/g9wAS7ABW4giBshQZji3AAAAABJRU5ErkJggg==";
const phoneUtil = PhoneNumberUtil.getInstance();

export default class PhoneInput extends PureComponent {
constructor(props) {
Expand Down Expand Up @@ -59,8 +58,7 @@ export default class PhoneInput extends PureComponent {
isValidNumber = (number) => {
try {
const { countryCode } = this.state;
const parsedNumber = phoneUtil.parse(number, countryCode);
return phoneUtil.isValidNumber(parsedNumber);
return isValidPhoneNumber(number, countryCode);
} catch (err) {
return false;
}
Expand Down Expand Up @@ -240,8 +238,7 @@ export default class PhoneInput extends PureComponent {

export const isValidNumber = (number, countryCode) => {
try {
const parsedNumber = phoneUtil.parse(number, countryCode);
return phoneUtil.isValidNumber(parsedNumber);
return isValidPhoneNumber(number, countryCode);
} catch (err) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"android"
],
"dependencies": {
"google-libphonenumber": "^3.2.10",
"libphonenumber-js": "^1.9.49",
"react-native-country-picker-modal": "^2.0.0"
},
"devDependencies": {
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -700,11 +700,6 @@ globals@^11.1.0:
resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e"
integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==

google-libphonenumber@^3.2.10:
version "3.2.10"
resolved "https://registry.yarnpkg.com/google-libphonenumber/-/google-libphonenumber-3.2.10.tgz#021a314652747d736a39e2e60dc670f0431425ad"
integrity sha512-TsckE9O8QgqaIeaOXPjcJa4/kX3BzFdO1oCbMfmUpRZckml4xJhjJVxaT9Mdt/VrZZkT9lX44eHAEWfJK1tHtw==

has-flag@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
Expand Down Expand Up @@ -744,6 +739,11 @@ json5@^2.1.2:
dependencies:
minimist "^1.2.5"

libphonenumber-js@^1.9.49:
version "1.9.49"
resolved "https://registry.yarnpkg.com/libphonenumber-js/-/libphonenumber-js-1.9.49.tgz#d431703cd699be2ccced5b95f26182a7c50a9227"
integrity sha512-/wEOIONcVboFky+lWlCaF7glm1FhBz11M5PHeCApA+xDdVfmhKjHktHS8KjyGxouV5CSXIr4f3GvLSpJa4qMSg==

lodash.toarray@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.toarray/-/lodash.toarray-4.4.0.tgz#24c4bfcd6b2fba38bfd0594db1179d8e9b656561"
Expand Down