-
Added
parseNumber()
andformatNumber()
aliases forparse()
andformat()
. Now these are the default ones, andparse()
andformat()
names are considered deprecated. The rationale is thatparse()
andformat()
function names are too unspecific and can clash with other functions declared in a javascript file. And also searching in a project forparseNumber
andformatNumber
is easier than searching in a project forparse
andformat
. -
Fixed
parseRFC3966()
andformatRFC3966()
non-custom exports.
parse()
is now more forgiving when parsing invalid international numbers. E.g.parse('+49(0)15123020522', 'DE')
doesn't return{}
and instead removes the invalid(0)
national prefix from the number.
- Added
PhoneNumberSearch
class for asynchronous phone number search.
- Added
findPhoneNumbers
function.
- Added
parseRFC3966
andformatRFC3966
functions which are exported.
- Fixed custom metadata backwards compatibility bug introduced in
1.0.16
. All people who previously installed1.0.16
or1.0.17
should update. - Refactored metadata module which now supports versioning by adding the
version
property to metadata JSON.
- Fixed
RFC3966
format not prependingtel:
to the output. - Renamed
{ possible: true }
option to{ extended: true }
and the result is now more verbose (see the README). - Added
possible_lengths
property in metadata: metadata generated using previous versions of the library should be re-generated with then new version.
- (experimental) Added
{ possible: true }
option forparse()
for parsing "possible numbers" which are not considered valid (like Google's demo does). E.g.parse('+71111111111', { possible: true }) === { countryCallingCode: '7', phone: '1111111111', possible: true }
andformat({ countryCallingCode: '7', phone: '1111111111' }, 'E.164') === '+71111111111'
. getPhoneCode
name is deprecated, usegetCountryCallingCode
instead.getPhoneCodeCustom
name is deprecated, usegetCountryCallingCodeCustom
instead.AsYouType.country_phone_code
renamed toAsYouType.countryCallingCode
(but no one should have used that property).
- If
country: string
argument is passed toparse()
now it becomes "the default country" rather than "restrict to country" ("restrict to country" option is gone). parse()
options
argument changed: it's now an undocumented feature and can have only a single option inside —defaultCountry: string
— which should be passed as a string argument instead.- Removed all previously deprecated stuff: all underscored exports (
is_valid_number
,get_number_type
andas_you_type
), lowercase exports forasYouType
andasYouTypeCustom
(useAsYouType
andAsYouTypeCustom
instead),"International_plaintext"
format (use"E.164"
instead). - Integer phone numbers no longer get automatically converted to strings.
parse()
,isValidNumber()
,getNumberType()
andformat()
no longer acceptundefined
phone number argument: it must be either a string or a parsed number object having a stringphone
property.
- Added
formatExtension(number, extension)
option toformat()
- Added support for phone number extensions.
asYouType
name is deprecated, useAsYouType
instead (same goes forasYouTypeCustom
).is_valid_number
,get_number_type
andas_you_type
names are deprecated, use camelCased names instead.International_plaintext
format is deprecated, useE.164
instead.- Added
RFC3966
format for phone number URIs (tel:+1213334455;ext=123
).
- Added missing
getNumberTypeCustom
es6 export
- Removed
.valid
from "as you type" formatter because it wasn't reliable (gave false negatives). UseisValidNumber(value)
for phone number validation instead.
- Fixed a bug when "as you type" formatter incorrectly formatted the input using non-matching phone number formats
- Loosened national prefix requirement when parsing (fixed certain Brazilian phone numbers parsing)
- Added more strict validation to
isValidNumber
- Fixed CommonJS export for
getNumberType
- Now exporting
getNumberType
function
- Removed
libphonenumber-js/custom.es6
exported file: now everything should be imported from the root package in ES6-capable bundlers (because tree-shaking actually works that way) - Now custom functions like
parse
,format
andisValidNumber
are not bound to custom metadata: it's passed as the last argument instead. And customasYouType
is now not a function — instead,asYouType
constructor takes an additionalmetadata
argument
- Fixed
update-metadata
utility
- Added national prefix check for
parse
andisPhoneValid
- A bit more precise
valid
flag for "as you type" formatter
- Added metadata update
bin
command for end users (see README) - Added the ability to include extra regular expressions for finer-grained phone number validation
- Added the ability to use custom-countries generated metadata as a parameter for the functions exported from this library
- Small fix for "as you type" to not prepend national prefix to the number being typed
- Reset
default_country
for "as you type" if the input is an international phone number
- (misc) Small fix for
format()
when the national number isundefined
- Better "as you type" matching: when the national prefix is optional it now tries both variants — with the national prefix extracted and without
- Exporting
metadata
andgetPhoneCode()
- Fixed a minor bug in "as you type" when a local phone number without national prefix got formatted with the national prefix
- Fixed a bug when country couldn't be parsed from a phone number in most cases
- Added
.country_phone_code
readable property to "as you type" formatter
- "As you type" formatter's
country_code
argument is nowdefault_country_code
, and it doesn't restrict to the specified country anymore.
- "As you type" formatter
template
fix for national prefixes (which weren't replaced withx
-es)
- "As you type" formatter now formats the whole input passed to the
.input()
function one at a time without splitting it into individual characters (which yields better performance)
- Added
valid
,country
andtemplate
fields to "as you type" instance
- Managed to reduce metadata size by another 5 KiloBytes removing redundant (duplicate) phone number type regular expressions (because there's no "get phone type" API in this library).
- Managed to reduce metadata size by 10 KiloBytes removing phone number type regular expressions when
leading_digits
are present.
- Turned out those numerous bulky regular expressions (
<fixedLine/>
,<mobile/>
, etc) are actually required to reliably infer country from country calling code and national phone number in cases where there are multiple countries assigned to the same country phone code (e.g. NANPA), so I've included those big regular expressions for those ambiguous cases which increased metadata size by 20 KiloBytes resulting in a total of 90 KiloBytes for the metadata.
- Small fix for "as you type" formatter: replacing digit placeholders (punctuation spaces) with regular spaces in the output
- Fixed a bug when national prefix
1
was present in "as you type" formatter for NANPA countries (while it shouldn't have been present)
- (may be a breaking change) renamed
.clear()
to.reset()
for "as you type" formatter
- Better
asYouType
(better than Google's original "as you type" formatter)
- Added
asYouType
andisValidNumber
.
- Added
format
function.
- Initial release.
parse
function is working.