A joi extension used to validate/parse phone numbers.
Internally it is using Google’s library libphonenmber.
Require the lib if using ES5
var phoneValidator = require('joi-phone-validator');Import the module if using ES6
import phoneValidator from 'joi-phone-validator'Validate phone number format
var schema = phoneValidator.phone().validate()
var result = Joi.validate('+33123456789', schema)
// result.error -> null
// result.value -> '+33123456789'Validate phone number is mobile
var schema = phoneValidator.phone().mobile()
var result = Joi.validate('+33623456789', schema)
// result.error -> null
// result.value -> '+33623456789'Functions are composable
var schema = phoneValidator.phone().validate().mobile()For others use cases, you can look at the tests in the test directory.