A phone validator for Joi.
joi-phone
validates that a value is a valid international phone number complying to E.164
numbering format
An international E.164 number is designed to include all of the necessary information to successfully route a call to an individual subscriber on a nation's public telephone network. Here's how the E.164 numbering plan works:
- A telephone number can have a maximum of 15 digits
- The first part of the telephone number is the country code (one to three digits)
- The second part is the national destination code (NDC)
- The last part is the subscriber number (SN)
- The NDC and SN together are collectively called the national (significant) number
[+][country code][subscriber number including area code or national (significant) number]
var Joi = require('joi');
Joi.phone = require('joi-phone');
var schema = {
phone: Joi.phone.e164()
}
npm install joi-phone --save
npm test