isPossibleNumber.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports["default"] = isPossibleNumber;
  6. var _getNumberType = require("./getNumberType.js");
  7. var _isPossible = _interopRequireDefault(require("../isPossible.js"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9. /**
  10. * Checks if a given phone number is possible.
  11. * Which means it only checks phone number length
  12. * and doesn't test any regular expressions.
  13. *
  14. * Examples:
  15. *
  16. * ```js
  17. * isPossibleNumber('+78005553535', metadata)
  18. * isPossibleNumber('8005553535', 'RU', metadata)
  19. * isPossibleNumber('88005553535', 'RU', metadata)
  20. * isPossibleNumber({ phone: '8005553535', country: 'RU' }, metadata)
  21. * ```
  22. */
  23. function isPossibleNumber() {
  24. var _normalizeArguments = (0, _getNumberType.normalizeArguments)(arguments),
  25. input = _normalizeArguments.input,
  26. options = _normalizeArguments.options,
  27. metadata = _normalizeArguments.metadata; // `parseNumber()` would return `{}` when no phone number could be parsed from the input.
  28. if (!input.phone && !(options && options.v2)) {
  29. return false;
  30. }
  31. return (0, _isPossible["default"])(input, options, metadata);
  32. }
  33. //# sourceMappingURL=isPossibleNumber.js.map