Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var numberObj = phoneUtil.parseAndKeepRawInput(number, countryCode);
return phoneUtil.isPossibleNumberWithReason(numberObj);
} catch (e) {
//console.log(e);
// here I convert thrown errors into ValidationResult enums (if possible)
if (e == libphonenumber.Error.INVALID_COUNTRY_CODE) {
return libphonenumber.PhoneNumberUtil.ValidationResult.INVALID_COUNTRY_CODE;
}
if (e == libphonenumber.Error.NOT_A_NUMBER) {
return 4;
}
if (e == libphonenumber.Error.TOO_SHORT_AFTER_IDD || e == libphonenumber.Error.TOO_SHORT_NSN) {
return libphonenumber.PhoneNumberUtil.ValidationResult.TOO_SHORT;
}
if (e == libphonenumber.Error.TOO_LONG) {
return libphonenumber.PhoneNumberUtil.ValidationResult.TOO_LONG;
}
// broken
return -99;
}
}
function getValidationError(number, countryCode) {
try {
var phoneUtil = libphonenumber.PhoneNumberUtil.getInstance();
var numberObj = phoneUtil.parseAndKeepRawInput(number, countryCode);
return phoneUtil.isPossibleNumberWithReason(numberObj);
} catch (e) {
//console.log(e);
// here I convert thrown errors into ValidationResult enums (if possible)
if (e == libphonenumber.Error.INVALID_COUNTRY_CODE) {
return libphonenumber.PhoneNumberUtil.ValidationResult.INVALID_COUNTRY_CODE;
}
if (e == libphonenumber.Error.NOT_A_NUMBER) {
return 4;
}
if (e == libphonenumber.Error.TOO_SHORT_AFTER_IDD || e == libphonenumber.Error.TOO_SHORT_NSN) {
return libphonenumber.PhoneNumberUtil.ValidationResult.TOO_SHORT;
}
if (e == libphonenumber.Error.TOO_LONG) {
return libphonenumber.PhoneNumberUtil.ValidationResult.TOO_LONG;
}
// broken
return -99;
}
}
function getValidationError(number, countryCode) {
try {
var phoneUtil = libphonenumber.PhoneNumberUtil.getInstance();
var numberObj = phoneUtil.parseAndKeepRawInput(number, countryCode);
return phoneUtil.isPossibleNumberWithReason(numberObj);
} catch (e) {
//console.log(e);
// here I convert thrown errors into ValidationResult enums (if possible)
if (e == libphonenumber.Error.INVALID_COUNTRY_CODE) {
return libphonenumber.PhoneNumberUtil.ValidationResult.INVALID_COUNTRY_CODE;
}
if (e == libphonenumber.Error.NOT_A_NUMBER) {
return 4;
}
if (e == libphonenumber.Error.TOO_SHORT_AFTER_IDD || e == libphonenumber.Error.TOO_SHORT_NSN) {
return libphonenumber.PhoneNumberUtil.ValidationResult.TOO_SHORT;
}
if (e == libphonenumber.Error.TOO_LONG) {
return libphonenumber.PhoneNumberUtil.ValidationResult.TOO_LONG;
}
// broken
return -99;
}
}
function getValidationError(number, countryCode) {
try {
var phoneUtil = libphonenumber.PhoneNumberUtil.getInstance();
var numberObj = phoneUtil.parseAndKeepRawInput(number, countryCode);
return phoneUtil.isPossibleNumberWithReason(numberObj);
} catch (e) {
//console.log(e);
// here I convert thrown errors into ValidationResult enums (if possible)
if (e == libphonenumber.Error.INVALID_COUNTRY_CODE) {
return libphonenumber.PhoneNumberUtil.ValidationResult.INVALID_COUNTRY_CODE;
}
if (e == libphonenumber.Error.NOT_A_NUMBER) {
return 4;
}
if (e == libphonenumber.Error.TOO_SHORT_AFTER_IDD || e == libphonenumber.Error.TOO_SHORT_NSN) {
return libphonenumber.PhoneNumberUtil.ValidationResult.TOO_SHORT;
}
if (e == libphonenumber.Error.TOO_LONG) {
return libphonenumber.PhoneNumberUtil.ValidationResult.TOO_LONG;
}
// broken
return -99;
}
}