-
-
Notifications
You must be signed in to change notification settings - Fork 2k
utils.js
utils.js (found in lib/libphonenumber/build/) is a custom build of Google's libphonenumber library. It provides the following methods/enums, all namespaced under the global intlTelInputUtils, which are used by the plugin, but can also be used directly by you if needed.
Note: countryCode is optional (you can pass null) if number is a full international number.
formatNumber(number, countryCode)
Uses the AsYouTypeFormatter to apply formatting to incomplete numbers.
formatNumberByType(number, countryCode, format)
Format the given (valid) number according to the given format (a numberFormat enum)
getExampleNumber(countryCode, isNational, format)
Get an example number for the given country. isNational is a bool, format is a numberFormat enum.
getNumberType(number, countryCode)
Get the type of the given number (returns a numberType enum).
getValidationError(number, countryCode)
If a number is invalid, then you can call this to get the reason (returns a validationError enum).
isValidNumber(number, countryCode)
Return a boolean for if the given number is valid.
See the build file for more info - the enums are towards the end.
numberFormat
e.g. INTERNATIONAL, NATIONAL
numberType
e.g. FIXED_LINE, MOBILE
validationError
e.g. INVALID_COUNTRY_CODE, TOO_SHORT