Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

127
Vistas
Issue with libphonenumber-js library not formatting international numbers

I'm trying to get international phone numbers to format properly but it doesn't seem to be adding the spaces within the number, only for the country code.

let phoneNumber = parsePhoneNumber('+3802342342345', 'UA');
return phoneNumber.formatInternational();

So the result I would expect to see is:

+380 234 234 2345

but instead I get

+380 2342342345

without the spaces in the actual phone number.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Seems like your number is invalid. Some of the number formats I found here

let phoneNumber = libphonenumber.parsePhoneNumber('+3802342342345', 'UA').formatInternational();;
console.log(phoneNumber)
console.log(libphonenumber.isValidNumber(phoneNumber))

//+380 44 xxx-xx-xx  (international call to Kyiv)
let a = libphonenumber.parsePhoneNumber('+380444234245', 'UA').formatInternational();
console.log(a)
console.log(libphonenumber.isValidNumber(a))

//+380 45 94x-xx-xx  (international call to Brovary)
let b = libphonenumber.parsePhoneNumber('+380459434245', 'UA').formatInternational();
console.log(b)
console.log(libphonenumber.isValidNumber(b))

//+380 48 xxx-xx-xx  (international call to Odessa)
let c = libphonenumber.parsePhoneNumber('+380489434245', 'UA').formatInternational();
console.log(c)
console.log(libphonenumber.isValidNumber(c))

//+380 48 2xx-xx-xx  (international call to 6-digit numbers in Odessa)
let d = libphonenumber.parsePhoneNumber('+380482434245', 'UA').formatInternational();
console.log(d)
console.log(libphonenumber.isValidNumber(d))
<script src="https://cdnjs.cloudflare.com/ajax/libs/libphonenumber-js/1.9.48/libphonenumber-js.min.js"></script>

The library seems to take the default digits together

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda