Skip to content

(Meteor wrapper) Javascript library for parsing, formatting, storing and validating international phone numbers

Notifications You must be signed in to change notification settings

emgee3/meteor-libphonenumber

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEPRECATED

As of Meteor 1.3 this wrapper is no longer needed. No further updates will be done.

meteor-libphonenumber

Meteor wrapper of google-libphonenuber, itself a wrapper of libphonenumber.

Javascript library for parsing, formatting, storing and validating international phone numbers

Exports LibPhoneNumber on server only.

####Example usage:

if (Meteor.isServer()) {
  var util = LibPhoneNumber.PhoneNumberUtil.getInstance();
  var format = LibPhoneNumber.PhoneNumberFormat;
  var types = LibPhoneNumber.PhoneNumberType;

  function getKey (obj, val) {
    for (var prop in obj) {
      if (obj.hasOwnProperty(prop))
        if (obj[prop] === val)
          return prop;
    }
  };

  function parsePhone (opts) {
    var parsedNumber = util.parse(opts.phone, opts.country || "US");
    var type = getKey(types, util.getNumberType(parsedNumber));

   return {
      phone   : util.format(parsedNumber, format.E164),
      isValid : util.isValidNumber(parsedNumber),
      type    : type
    };
  }
}

About

(Meteor wrapper) Javascript library for parsing, formatting, storing and validating international phone numbers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published