1.0.0 • Published 6 years ago
joi-ext-phone-number v1.0.0
joi-ext-phone-number
Joi extension for phone number rules.
This uses google-libphonenumber for validation. An alternative Joi extension for phone number validation that support for Joi v16+.
This extended from Joi.string() base. So allows you define schema by Joi.string().phoneNumber().
Compability
This Joi extension requires joi v16 or newer.
If you are unfamiliar with Joi, maybe you should read Joi Documentation and API
Installation
$ npm install joi-ext-phone-number --saveUsage
const Joi = require('@hapi/joi');
const customJoi = Joi.extend(require('joi-ext-phone-number'));
const schema = customJoi.string().phoneNumber();
// or by options
const customSchema = customJoi.string().phoneNumber({
defaultRegionCode: 'US',
format: 'e164',
strict: false
});For more usage, check it out under test directory.
1.0.0
6 years ago