# joi-phone-number **Published by:** [SomewhereSomehowSomewhat](https://paragraph.com/@somewheresomehowsomewhat/) **Published on:** 2022-01-04 **URL:** https://paragraph.com/@somewheresomehowsomewhat/joi-phone-number ## Content What Allows you to do Joi.string().phoneNumber(). Uses https://github.com/ruimarinho/google-libphonenumber for validation. Which is a compiled version of the Google library https://github.com/googlei18n/libphonenumber. const myCustomJoi = Joi.extend(require('joi-phone-number')); myCustomJoi.string().phoneNumber().validate('+32494567324'); // The phone number can be transformed to a custom format // Note that this follows Joi's `convert` option myCustomJoi.string().phoneNumber({ defaultCountry: 'BE', format: 'e164' }).validate('494322456'); // '+32494322456' myCustomJoi.string().phoneNumber({ defaultCountry: 'BE', format: 'international' }).validate('494322456'); // '+32 494 32 24 56' myCustomJoi.string().phoneNumber({ defaultCountry: 'BE', format: 'national' }).validate('494322456'); // '0494 32 24 56' myCustomJoi.string().phoneNumber({ defaultCountry: 'BE', format: 'rfc3966' }).validate('494322456'); // 'tel:+32-494-32-24-56' myCustomJoi.string().phoneNumber({ defaultCountry: 'US', strict: true }).validate('7777777777'); // validation error myCustomJoi.string().phoneNumber({ defaultCountry: 'US'}).validate('7777777777'); // 7777777777 ## Publication Information - [SomewhereSomehowSomewhat](https://paragraph.com/@somewheresomehowsomewhat/): Publication homepage - [All Posts](https://paragraph.com/@somewheresomehowsomewhat/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@somewheresomehowsomewhat): Subscribe to updates