1.0.1 • Published 4 years ago

joi-international-phone v1.0.1

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

What

Allows you to do joi.internationalPhone()

Uses https://github.com/ruimarinho/google-libphonenumber for validation.

Which is a compiled version of the Google library https://github.com/googlei18n/libphonenumber.

How

const joi = require('joi')
    .extend(require('joi-international-phone'));

const schema = joi.object({
    phone: joi.internationalPhone()
});

schema.validate('+ 55 55 99730 0000'); 
// {
//    value: '+55 55 99730-0000',
//    error: null
// }

schema.validate('not a phone');
// {
//    value: 'not a phone',
//    error: 'The string supplied did not seem to be a phone number'
// }