Joi Phone Number
Joi Phone Number is validation rule for Joi.

Installation
$ npm i joi-phone-number-validation
Usage
const { JoiPhoneNumber, RETURNING_FORMAT } = require("joi-phone-number-validation");
const schema = JoiPhoneNumber.string().phoneNumber({
returningFormat: RETURNING_FORMAT.NATIONAL,
});
const { value, error } = schema.validate('+2010 605 944 88');
const schema = JoiPhoneNumber.string().phoneNumber({
returningFormat: RETURNING_FORMAT.INTERNATIONAL,
});
const { value, error } = schema.validate('+2010 605 944 88');
const schema = JoiPhoneNumber.string().phoneNumber({
returningFormat: RETURNING_FORMAT.ORIGINAL,
});
const { value, error } = schema.validate('+2010 605 944 88');
const schema = JoiPhoneNumber.string().phoneNumber({
returningFormat: RETURNING_FORMAT.FORMATTED_VALUE,
});
const { value, error } = schema.validate('+2010 605 944 88');
const schema = JoiPhoneNumber.string().phoneNumber({
returningFormat: RETURNING_FORMAT.RFC3966,
});
const { value, error } = schema.validate('+2010 605 944 88');
const schema = JoiPhoneNumber.string().phoneNumber({
returningFormat: RETURNING_FORMAT['E.164'],
});
const { value, error } = schema.validate('+2010 605 944 88');
const schema = JoiPhoneNumber.string().phoneNumber({
returningFormat: RETURNING_FORMAT.VALUE_WITH_EXTRA_INFO,
});
const { value, error } = schema.validate('+2010 605 944 88');
Tests
To run the test suite, first install the dependencies then run npm test
:
$ npm install
$ npm test
Support
Feel free to open issues on github.