isPossibleNumber.js 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. import { normalizeArguments } from './getNumberType.js';
  2. import _isPossibleNumber from '../isPossible.js';
  3. /**
  4. * Checks if a given phone number is possible.
  5. * Which means it only checks phone number length
  6. * and doesn't test any regular expressions.
  7. *
  8. * Examples:
  9. *
  10. * ```js
  11. * isPossibleNumber('+78005553535', metadata)
  12. * isPossibleNumber('8005553535', 'RU', metadata)
  13. * isPossibleNumber('88005553535', 'RU', metadata)
  14. * isPossibleNumber({ phone: '8005553535', country: 'RU' }, metadata)
  15. * ```
  16. */
  17. export default function isPossibleNumber() {
  18. var _normalizeArguments = normalizeArguments(arguments),
  19. input = _normalizeArguments.input,
  20. options = _normalizeArguments.options,
  21. metadata = _normalizeArguments.metadata; // `parseNumber()` would return `{}` when no phone number could be parsed from the input.
  22. if (!input.phone && !(options && options.v2)) {
  23. return false;
  24. }
  25. return _isPossibleNumber(input, options, metadata);
  26. }
  27. //# sourceMappingURL=isPossibleNumber.js.map