HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux ip-172-31-4-197 6.8.0-1036-aws #38~22.04.1-Ubuntu SMP Fri Aug 22 15:44:33 UTC 2025 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/api-parametros/node_modules/libphonenumber-js/es6/legacy/isValidNumberForRegion.js
import isViablePhoneNumber from '../helpers/isViablePhoneNumber.js';
import parseNumber from '../parse.js';
import _isValidNumberForRegion from './isValidNumberForRegion_.js'; // This function has been deprecated and is not exported as
// `isValidPhoneNumberForCountry()` or `isValidPhoneNumberForRegion()`.
//
// The rationale is:
//
// * We don't use the "region" word, so "country" would be better.
//
// * It could be substituted with:
//
// ```js
// export default function isValidPhoneNumberForCountry(phoneNumberString, country) {
// 	const phoneNumber = parsePhoneNumber(phoneNumberString, {
// 		defaultCountry: country,
// 		// Demand that the entire input string must be a phone number.
// 		// Otherwise, it would "extract" a phone number from an input string.
// 		extract: false
// 	})
// 	if (!phoneNumber) {
// 		return false
// 	}
// 	if (phoneNumber.country !== country) {
// 		return false
// 	}
// 	return phoneNumber.isValid()
// }
// ```
//
// * Same function could be used for `isPossiblePhoneNumberForCountry()`
//   by replacing `isValid()` with `isPossible()`.
//
// * The reason why this function is not exported is because its result is ambiguous.
//   Suppose `false` is returned. It could mean any of:
//   * Not a phone number.
//   * The phone number is valid but belongs to another country or another calling code.
//   * The phone number belongs to the correct country but is not valid digit-wise.
//   All those three cases should be handled separately from a "User Experience" standpoint.
//   Simply showing "Invalid phone number" error in all of those cases would be lazy UX.

export default function isValidNumberForRegion(number, country, metadata) {
  if (typeof number !== 'string') {
    throw new TypeError('number must be a string');
  }

  if (typeof country !== 'string') {
    throw new TypeError('country must be a string');
  } // `parse` extracts phone numbers from raw text,
  // therefore it will cut off all "garbage" characters,
  // while this `validate` function needs to verify
  // that the phone number contains no "garbage"
  // therefore the explicit `isViablePhoneNumber` check.


  var input;

  if (isViablePhoneNumber(number)) {
    input = parseNumber(number, {
      defaultCountry: country
    }, metadata);
  } else {
    input = {};
  }

  return _isValidNumberForRegion(input, country, undefined, metadata);
}
//# sourceMappingURL=isValidNumberForRegion.js.map